-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Get a console error if you open a project using "Application Support" or its parent folder. #7300
Comments
Add step 2 that is necessary for the console error. This issue was discovered when helping @lkcampbell's to identify the cause of #7299. I was able to reproduce #7299 when dragging the entire user folder as the project root, but not with "Application Support" folder. |
I'm almost positive the problem is the File entry for |
Also, seems unlikely to be Mac-only... just easier to hit on Mac since opening |
Hmm, interestingly though FileStorage.save() & load() fetch a new File object every time... so either someone else is holding onto that entry, or something else funny is going on... |
Remove mac only label since I can reproduce it on Windows also. |
Ok, I figured out what's going on:
So, I think this is all normal & correct FileSystem behavior -- by design, you're not supposed to be able to write to a file if we don't have a guarantee that you've read it before. That constraint doesn't really make sense for the preferences code. So I think we should fix this by having PreferencesBase pass the We could instead try to do something clever to retain the old hash, or re-read CC @iwehrman @gruehle @dangoor in case you guys might have different opinions. If not I can put up a PR with the simple fix tomorrow. |
Btw @dangoor can you think of any reasonably simple way to unit-test the fix for this? Now that the prefs unit tests all use in-memory storage it seems tricky. |
As long as the |
Hmm, the @dangoor Any thoughts here? Personally I'm leaning toward the simple fix, given that we think we've gotten watchers to be pretty reliable at this point... |
Actually, I just realized the preferences system doesn't use file watchers -- |
@peterflynn Yeah, I agree that we'd want to prefer the changes that the user makes and just write to the file, but only as long as we're watching the file for external changes. |
Hrm, actually I forgot a critical point in all this: up until now we've never exercised the FileSystem code with multiple "watch roots" active at once. In theory it all works, but I'd be leery of starting to rely on it now without a ton of testing runway. And there's one further wrinkle: it doesn’t currently allow overlapping roots, so we'd have to unwatch the prefs file whenever opening a project root that includes that file in its subtree, and rewatch the prefs file whenever we close such a project. So I think for now it may actually be cleaner to do something hacky, like forcibly re-read the prefs file from disk whenever we switch away from a project that contained it... |
Yes, I think you're right that a simpler solution (even if it feels a little hacky) is a better choice right now. |
contains the user prefs JSON files in its subtree) - ensure that FileSystem always knows we've read the JSON file before we try to write to it. We don't want to enable the 'blind' flag since it will mean we virtually always overwrite external changes to the prefs file, and we don't want to start using file watchers to observe external changes on the fly since we haven't yet deeply tested having multiple watch roots active at once. - Rename confusing "filename" vars in PreferencesBase - Fix JSLint errors in ProjectManager from #7026
I've spun off #7375 for using file watchers to get nicer behavior |
Fix bug #7300 (Prefs never saved again after opening ancestor folder of user prefs.json)
Oops, forgot to reassign - FBNC @RaymondLim |
Confirmed fixed. |
Just an FYI, confirmed that issue #7299 is fixed as well. Thanks. |
@lkcampbell Thanks, good to have the confirmation! |
Result: You will see one console error.
Although we allow blind write in sprint 36, we're not updating state.json in this case. (or maybe an out-of-order overwrite is taking out all the newly updates).
If you restart or reload Brackets, you will see the project you opened in step 1 as current project, not the one you switched in step 2 even if it is the default Getting Started project (issue #7299). Note that you can also reproduce it with Brackets cache folder.
The text was updated successfully, but these errors were encountered: