summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-22 04:41:31 +0200
committerhut <hut@lavabit.com>2011-10-22 04:41:31 +0200
commit63c7a6803f9d3f80f559c891bb131caad0271588 (patch)
tree3716bdaefe4fd0ed136da9bb4685f454c95f4e5b
parentb2b58e7f15e5700a1f8248fb1bf32386b4b45c57 (diff)
downloadranger-63c7a6803f9d3f80f559c891bb131caad0271588.tar.gz
fsobject.directory: Add a "?" when unsure about the size
-rw-r--r--ranger/fsobject/directory.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 04ed35e0..fd4679ce 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -81,6 +81,7 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 	content_loaded = False
 
 	_cumulative_size_calculated = False
+	_cumulative_size_needs_update = False
 
 	sort_dict = {
 		'basename': sort_by_basename,
@@ -188,14 +189,19 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 				hidden_filter = not self.settings.show_hidden \
 						and self.settings.hidden_filter
 				filelist = os.listdir(mypath)
-				if not self._cumulative_size_calculated \
-						or self.content_loaded:
+
+				if self._cumulative_size_calculated:
+					if self.content_loaded:
+						self._cumulative_size_needs_update = True
+					self.infostring = '%s' % (human_readable(
+						self.size, seperator=\
+						('? ' if self._cumulative_size_needs_update else ' ')))
+				else:
 					self.size = len(filelist)
 					self.infostring = ' %d' % self.size
-				if self._cumulative_size_calculated:
-					self._cumulative_size_calculated = False
 				if self.is_link:
 					self.infostring = '->' + self.infostring
+
 				filenames = [mypath + (mypath == '/' and fname or '/' + fname)\
 						for fname in filelist if accept_file(
 							fname, mypath, hidden_filter, self.filter)]
@@ -354,12 +360,13 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 		return cum
 
 	def look_up_cumulative_size(self):
-		if not self._cumulative_size_calculated:
+		if self._cumulative_size_needs_update or \
+				not self._cumulative_size_calculated:
 			self._cumulative_size_calculated = True
-			cum = self._get_cumulative_size()
-			self.size = cum
+			self._cumulative_size_needs_update = False
+			self.size = self._get_cumulative_size()
 			self.infostring = ('-> ' if self.is_link else ' ') + \
-					human_readable(cum)
+					human_readable(self.size)
 
 	@lazy_property
 	def size(self):