Closed emr4378 closed 9 years ago
Thanks for your contribution. I'll have a look into it to make sure it's not too intrusive. For instance, I'm afraid it may eventually remove potential execution rights; this is an edge case, but I'd prefer this file manipulation to be as transparent as possible. What do you think ?
Yeah, I could see that. I'm not a big fan of all the permission copying/changing but I was hoping to keep this change small and simple.
From my understanding we create this temp file so we can save the current changes to the actual file, build it, and then revert those changes. Would it be possible to just save the current changes to a temp file and build that? The original file permissions/content would be untouched which I think would be the best situation.
It used to work like this (save a temp file somewhere else, and complete using this temp file), but I think I remember it had issues with caching and stuff.
I had to fix it somehow, because it broke my setup. Can you confirm it still works for you ?
Grabbed the latest; the TMP files are cleaned up, but the original files are losing their original permissions (they're becoming writable/modifiable). I'm looking into it now.
Actually, what was it that was breaking in your setup?
Looking at the "fix chmod" CL (58cad47) by changing the permissions of the temp file prior to the copy2 back to the original file, we're no longer preserving the original file permissions. This will always make the original file writable which is what I'm looking to avoid.
Ok I didn't get that.
I'm not sure I understand how you can manipulate the original file's content (which we must do) without having write permission on it ?
Also, the diff shows that your version also had this chmod (https://github.com/clemos/haxe-sublime-bundle/commit/58cad4780c3ce19a5219dfa38d25556f800ac726#diff-f3ba8f3fffc5230baafc6351f6c6924cL1794) ?
What we can do is store the file's mod value before changing its permission in save_temp_file
, and then restore it in clear_temp_file
?
I'm able to modify the original file's content because Sublime does it's editing in a buffer; my file being read-only only becomes an issue when I go to save (but that problem is solved with another plugin; https://github.com/ericmartel/Sublime-Text-3-Perforce-Plugin).
But because this Haxe plugin starts saving the buffer to the original file right as I start editing we're running into this read-only/TMP file issue.
I still think my original commit was more correct; the TMP file will always preserve the original permissions until we need to delete it. But if it was breaking something in your setup the change must still need some tweaking.
Alternatively, roll back everything. I'm pretty sure I can setup the Perforce plugin to checkout immediately on edit and avoid this issue altogether. :)
My proposed solution to the issue I outlined in https://github.com/clemos/haxe-sublime-bundle/issues/180. Everything still seems to be working, but there's no more error message or *.tmp files popping up everywhere.