diff options
author | Alexander Buddenbrock <a.buddenbrock@ish.de> | 2015-02-12 16:14:33 +0100 |
---|---|---|
committer | Alexander Buddenbrock <a.buddenbrock@ish.de> | 2015-02-12 16:14:33 +0100 |
commit | 9c1f5c2a8c3c803c003babc67e2a933d663315ca (patch) | |
tree | a30acace2aa5e6856d3a2f418e708e4cce7df8f2 | |
parent | e37671c0e87a2406eb1199ba458b9020642f9ce9 (diff) | |
download | ranger-9c1f5c2a8c3c803c003babc67e2a933d663315ca.tar.gz |
Fix renaming with insufficient privileges
Closes #97 When renaming a file, the internal file pointer will be set to the new file name without checking if the file actually got renamed. This would cause the file pointer to be set to an invalid file if renaming failed because of bad privileges. With no valid file, the previev window will disappear. This patch adds a return value to the core renaming method so it can be checking by the caller. The rename command now checks if the rename succeeded and only then sets the new file pointer.
-rw-r--r-- | ranger/config/commands.py | 8 | ||||
-rw-r--r-- | ranger/core/actions.py | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index b6206666..5bad4472 100644 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -715,10 +715,10 @@ class rename(Command): if access(new_name, os.F_OK): return self.fm.notify("Can't rename: file already exists!", bad=True) - self.fm.rename(self.fm.thisfile, new_name) - f = File(new_name) - self.fm.thisdir.pointed_obj = f - self.fm.thisfile = f + if self.fm.rename(self.fm.thisfile, new_name): + f = File(new_name) + self.fm.thisdir.pointed_obj = f + self.fm.thisfile = f def tab(self): return self._tab_directory_content() diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 20fb2ae9..b3b8f50b 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -1302,3 +1302,5 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): os.renames(src, dest) except OSError as err: self.notify(err) + return False + return True |