afrog icon indicating copy to clipboard operation
afrog copied to clipboard

Unsaved changes lost if permission denied when saving on exit

Open einarmagnus opened this issue 11 years ago • 16 comments

If I open a file that I do not have permission to save and try to save it I get a popup telling me I lack permissions, e.g. Unable to save file: permission denied '/etc/hosts'. This seems reasonable (although I wish it would ask me for my sudo password instead). However, if I modify it and then close it, Atom will ask me if I want to save it, and when I click "yes", it closes the file and gives me that same popup that it failed to save. This means my work is lost. I don't think I have used an editor before that doesn't keep the file open if it fails to save and I believe this should be considered a bug, right?

I am on Chakra linux running 1.0.0 via http://chakraos.org/ccr/packages.php?ID=7252

einarmagnus avatar Jul 04 '15 20:07 einarmagnus

I just tried to reproduce this using Atom v1.0.1-dd36bbd on Mac OS X 10.10.3 and I got a dialog asking for my credentials. This may be a Linux-specific issue or perhaps something specific to Chakra Linux.

lee-dohm avatar Jul 04 '15 21:07 lee-dohm

The dialog for credentials is probably a linux thing if that works on a mac, hopefully that means it can be implemented on linux too! But that was just a side note, what happens if you follow my second paragraph?

einarmagnus avatar Jul 04 '15 21:07 einarmagnus

The same thing happens, I get a dialog asking for credentials. I get the permission denied notification and the file closes if I click Cancel on the credentials dialog, but that should probably be filed as a separate bug.

In general, it is best to file separate Issues for separate bugs. This way there is no confusion over which bug it is you want fixed and which is a "side note" :grinning:

lee-dohm avatar Jul 04 '15 22:07 lee-dohm

Yeah, of course. I did not expect anyone to read my text as reporting a bug about the credentials thing, only about the loss of unsaved work.

einarmagnus avatar Jul 04 '15 22:07 einarmagnus

So to summarize this bug properly: When closing a tab with unsaved contents, Atom asks whether you want to save it or not and if you choose "yes" but it fails to save it (with or without a credentials prompt), it still closes the tab. What it probably should do, imo, is to inform the user of the problem and ask whether they want to "save as", "cancel" or "discard changes".

einarmagnus avatar Jul 04 '15 22:07 einarmagnus

Sorry about the many references, I was too quick to push.

I have submitted a pull request now that fixes this issue: https://github.com/atom/atom/pull/7712

einarmagnus avatar Jul 05 '15 01:07 einarmagnus

It failed linting, so I changed || to ? and submitted a new pull request: https://github.com/atom/atom/pull/7713

einarmagnus avatar Jul 05 '15 01:07 einarmagnus

@einarmagnus For the future .. why not just push another commit into #7712 that fixes the linting? You push new commit into einarmagnus:master that is connected with that PR so it will get added into the PR automatically. After that Travis CI restarts and rechecks linting. Or am I missing something?

kubetz avatar Jul 05 '15 01:07 kubetz

I am new at using github like this, next time I'll try updating the PR :) This time it was approved by the buildbots!

einarmagnus avatar Jul 05 '15 02:07 einarmagnus

I hope someone with a mac can test whether it interacts properly with Atom asking for credentials on macs. I am not sure where that plugs in.

einarmagnus avatar Jul 05 '15 02:07 einarmagnus

@einarmagnus Good job with passing tests from our master and savior Travis CI :+1: !

My 2 kinda offtopic cents (hopefully factually correct): When you open a pull request, it gets connected to the branch you created the PR from until the PR is merged or closed. Sometimes that can backfire when you commit into the same branch something totally different and it suddenly appears in the PR (been there, done that and had to learn dark ways how to revert that :blush:). So it is a good idea to create a git branch for the fix/feature you are making PR for and then leave it like that and work in other branches.

kubetz avatar Jul 05 '15 02:07 kubetz

Ok, thank you for taking the time to explain. This time I think I will get away with it as I doubt I'll contribute with more anytime soon. I just wanted to see how difficult it would be to fix the issue I ran into. What better way to complain than to offer a solution? :)

einarmagnus avatar Jul 05 '15 08:07 einarmagnus

What better way to complain than to offer a solution? :)

I wish more people thought like you do, @einarmagnus :grinning:

lee-dohm avatar Jul 05 '15 15:07 lee-dohm

I'm having this problem on Ubuntu 14.04. Even though I'm opening Atom with sudo, still can not save file.

jeton-th avatar Nov 24 '15 18:11 jeton-th

I am having the same issue Even with "sudo atom", I still can not save file. Gives me "Unable to save file: Permission denied"

TakanashiOuken avatar Apr 07 '16 06:04 TakanashiOuken

This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

lock[bot] avatar Apr 08 '18 16:04 lock[bot]