diff options
author | hut <hut@lavabit.com> | 2010-04-14 15:54:38 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-14 15:54:38 +0200 |
commit | 1cf19f8f7c2a386b574676b938c31b6f3c707d76 (patch) | |
tree | 3a85de0fbaddea83b9f02cf6648dd6a89e225218 /ranger | |
parent | 57435fbf56e83fe9b73d51771b853b34cd7f41db (diff) | |
download | ranger-1cf19f8f7c2a386b574676b938c31b6f3c707d76.tar.gz |
fixed rarely occuring permission issue
The case where you're not allowed to read the destination of a link was not handled properly. This happens namely in the procfs.
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/fsobject/fsobject.py | 7 | ||||
-rw-r--r-- | ranger/gui/widgets/statusbar.py | 3 |
2 files changed, 5 insertions, 5 deletions
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index f2f440c1..516f02e6 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -76,7 +76,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.basename = basename(path) self.basename_lower = self.basename.lower() self.dirname = dirname(path) - self.realpath = realpath(path) + self.realpath = self.path try: lastdot = self.basename.rindex('.') + 1 @@ -172,6 +172,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.is_link = stat.S_ISLNK(self.stat.st_mode) if self.is_link: try: # try to resolve the link + self.readlink = os.readlink(self.path) + self.realpath = realpath(self.path) self.stat = os.stat(self.path) except: # it failed, so it must be a broken link pass @@ -219,9 +221,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.exists = False self.runnable = False - if self.is_link: - self.readlink = os.readlink(self.path) - def get_permission_string(self): if self.permissions is not None: return self.permissions diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index 52425943..bff3d8ad 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -164,7 +164,8 @@ class StatusBar(Widget): if target.is_link: how = target.exists and 'good' or 'bad' - left.add(' -> ' + target.readlink, 'link', how) + dest = target.readlink if target.readlink is not None else '?' + left.add(' -> ' + dest, 'link', how) else: if self.settings.display_size_in_status_bar and target.infostring: left.add(target.infostring) |