about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-25 06:33:54 +0100
committerhut <hut@lavabit.com>2009-12-25 06:33:54 +0100
commit7fe6d250b44c1f06d4b578b8cdbd4fb055dedc28 (patch)
tree93563cb9ea8cc34612fb0f306d13fbb01c7dea51
parentfd04cd6f354d7b6abdf55998253ff9a0ab55ecb2 (diff)
downloadranger-7fe6d250b44c1f06d4b578b8cdbd4fb055dedc28.tar.gz
schedule loading of directories whereever possible
-rw-r--r--ranger/fsobject/directory.py36
-rw-r--r--ranger/gui/widgets/filelist.py6
2 files changed, 21 insertions, 21 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index f5aeade4..136752f8 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -170,32 +170,33 @@ class Directory(FileSystemObject, SettingsAware):
 		self.loading = False
 		self.load_generator = None
 
-	def load_content(self, schedule=False):
+	def load_content(self, schedule=None):
 		"""
 		Loads the contents of the directory. Use this sparingly since
 		it takes rather long.
 		"""
 
-		self.load_once()
-		
-		if schedule is None:
-			schedule = self.size > 30
+		if not self.loading:
+			self.load_once()
+			
+			if schedule is None:
+				schedule = self.size > 30
+
+			if self.load_generator is None:
+				self.load_generator = self.load_bit_by_bit()
 
-		if self.load_generator is None:
-			self.load_generator = self.load_bit_by_bit()
+				if schedule and self.fm:
+					self.fm.loader.add(self)
+				else:
+					for _ in self.load_generator:
+						pass
+					self.load_generator = None
 
-			if schedule and self.fm:
-				self.fm.loader.add(self)
-			else:
+			elif not schedule or not self.fm:
 				for _ in self.load_generator:
 					pass
 				self.load_generator = None
 
-		elif not schedule or not self.fm:
-			for _ in self.load_generator:
-				pass
-			self.load_generator = None
-
 
 	def sort(self):
 		"""Sort the containing files"""
@@ -322,8 +323,7 @@ class Directory(FileSystemObject, SettingsAware):
 	def load_content_once(self, *a, **k):
 		"""Load the contents of the directory if not done yet"""
 		if not self.content_loaded:
-			if not self.loading:
-				self.load_content(*a, **k)
+			self.load_content(*a, **k)
 			return True
 		return False
 
@@ -351,7 +351,7 @@ class Directory(FileSystemObject, SettingsAware):
 			cached_mtime = 0
 
 		if real_mtime != cached_mtime:
-			self.load_content()
+			self.load_content(*a, **k)
 			return True
 		return False
 
diff --git a/ranger/gui/widgets/filelist.py b/ranger/gui/widgets/filelist.py
index 8b4443d3..999cfd12 100644
--- a/ranger/gui/widgets/filelist.py
+++ b/ranger/gui/widgets/filelist.py
@@ -74,7 +74,7 @@ class FileList(Widget):
 
 	def finalize(self):
 		if self.postpone_drawing:
-			self.target.load_content_if_outdated(schedule=None)
+			self.target.load_content_if_outdated()
 			self.draw_directory()
 			self.postpone_drawing = False
 
@@ -140,8 +140,8 @@ class FileList(Widget):
 				self.color_reset()
 				return
 
-		self.target.load_content_if_outdated()
-		self.target.sort_if_outdated()
+		if not self.target.load_content_if_outdated():
+			self.target.sort_if_outdated()
 
 		if self.main_display:
 			base_color.append('maindisplay')