Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

File locking interaction between Bracket and SimpLESS #2579

Closed
absqueued opened this issue Jan 17, 2013 · 8 comments · Fixed by adobe/brackets-shell#195
Closed

File locking interaction between Bracket and SimpLESS #2579

absqueued opened this issue Jan 17, 2013 · 8 comments · Fixed by adobe/brackets-shell#195
Assignees
Milestone

Comments

@absqueued
Copy link

I am using SimpLESS to compile my LESS CSS and Bracket is the editor to work. While saving the LESS file very often (mean while the LESS file is being watched by SimpLESS, in background) - I get security error (See image for error
SimpLESS - Bracket Error
).

Steps to repro:
a.) Create a LESS file
b.) Open it in Bracket
c.) Drag this LESS file over SimpLESS to watch (so that it will compile the LESS in to CSS file and you use it in page)
d.) Now write some styles in the LESS file - in Bracket. Do write few class, change a property save it. Again change a property - save it. Now you will see the same error.

Very few times it wont show the error while saving often - else it will show up. Wait for few mins or close Bracket & SimpLESS to fix that error.

@peterflynn
Copy link
Member

@shekhardesigner do you see the same problem with any other editor? For example, if you save changes twice rapidly in Notepad?

@ghost ghost assigned njx Jan 18, 2013
@njx
Copy link
Contributor

njx commented Jan 18, 2013

Reviewed. To me for investigation in Sprint 20, to see what's going on and investigate possible workarounds.

@njx
Copy link
Contributor

njx commented Jan 26, 2013

I can repro on Windows easily--the errors pop up often, though not every single time. After dragging the project folder to SimpLESS, I often get errors when trying to open the LESS file; if I do manage to open it (which I can sometimes do after rebooting Brackets), I often get errors when trying to save it. Other text editors don't appear to have this problem, so it's something about the way we're accessing the files.

@njx
Copy link
Contributor

njx commented Jan 26, 2013

It looks like setting our ReadFile/WriteFile APIs to set FILE_SHARE_READ "fixes" the problem. However, it's not clear why we happen to collide with SimpLESS so often. Looking at its source code (it's written in Titanium), it seems like it polls timestamps once a second. That's not that often, and (reading down into the Titanium source code) it seems like getting a timestamp just uses GetFileAttributesEx(); I would be surprised if that actually locks the file. So it's a bit of a mystery as to why the error happens so frequently.

The other issue with just setting FILE_SHARE_READ is that if we're actually writing the file, then it's conceivable that SimpLESS could get a half-written copy. This is basically #881.

We might want to consider waiting till we switch to Node for filesystem support to deal with this. On the other hand, it might be worth putting in a quick fix since this is pretty terrible once it starts happening. The danger is that an incomplete file might get read by SimpLESS.

I'm currently checking to see if other things that watch files (e.g. yeoman) have the same issue.

@njx
Copy link
Contributor

njx commented Jan 26, 2013

See also #2683, which isn't directly related to this bug but causes workflow issues when using external watchers like SimpLESS.

@njx
Copy link
Contributor

njx commented Jan 26, 2013

FYI, this doesn't seem to be an issue on Mac.

@njx
Copy link
Contributor

njx commented Jan 28, 2013

This was fixed via adobe/brackets-shell#195. @shekhardesigner, please check this in the Sprint 20 build when it comes out in a couple of weeks. Thanks!

@njx njx closed this as completed Jan 28, 2013
@absqueued
Copy link
Author

Many thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants