diff options
Diffstat (limited to 'ranger/core')
-rw-r--r-- | ranger/core/actions.py | 2 | ||||
-rw-r--r-- | ranger/core/environment.py | 12 | ||||
-rw-r--r-- | ranger/core/fm.py | 3 |
3 files changed, 9 insertions, 8 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 6f2b8606..6eef3d41 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -305,7 +305,7 @@ class Actions(EnvironmentAware, SettingsAware): def reset(self): """Reset the filemanager, clearing the directory buffer""" old_path = self.env.cwd.path - self.env.directories = {} + self.env.garbage_collect(-1) self.enter_dir(old_path) def toggle_boolean_option(self, string): diff --git a/ranger/core/environment.py b/ranger/core/environment.py index 8799229c..cdca9782 100644 --- a/ranger/core/environment.py +++ b/ranger/core/environment.py @@ -100,14 +100,14 @@ class Environment(SettingsAware): except KeyError: return directory - def garbage_collect(self): + def garbage_collect(self, age): """Delete unused directory objects""" - from ranger.fsobject.fsobject import FileSystemObject - for key in tuple(self.directories.keys()): + for key in tuple(self.directories): value = self.directories[key] - if isinstance(value, FileSystemObject): - if value.is_older_than(1200) and not value in self.pathway: - del self.directories[key] + if value.is_older_than(age): # and not value in self.pathway: + del self.directories[key] + if value.is_directory: + value.files = None def get_selection(self): if self.cwd: diff --git a/ranger/core/fm.py b/ranger/core/fm.py index aef10150..de22a86c 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -32,6 +32,7 @@ from ranger.fsobject import Loader CTRL_C = 3 TICKS_BEFORE_COLLECTING_GARBAGE = 100 +TIME_BEFORE_FILE_BECOMES_GARBAGE = 1200 class FM(Actions, SignalDispatcher): input_blocked = False @@ -141,7 +142,7 @@ class FM(Actions, SignalDispatcher): gc_tick += 1 if gc_tick > TICKS_BEFORE_COLLECTING_GARBAGE: gc_tick = 0 - env.garbage_collect() + env.garbage_collect(TIME_BEFORE_FILE_BECOMES_GARBAGE) except KeyboardInterrupt: # this only happens in --debug mode. By default, interrupts |