about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/environment.py4
-rw-r--r--ranger/fsobject/directory.py8
-rw-r--r--ranger/fsobject/fsobject.py47
3 files changed, 34 insertions, 25 deletions
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index e5deda07..49d92502 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -190,6 +190,10 @@ class Environment(SettingsAware, SignalDispatcher):
 		self.cwd = new_cwd
 
 		self.cwd.load_content_if_outdated()
+		if self.cwd.files:
+			for dir in self.cwd.files:
+				if dir.is_directory and dir.infostring == 'unknown':
+					dir.determine_infostring()
 
 		# build the pathway, a tuple of directory objects which lie
 		# on the path to the current directory.
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 29f0042c..1c8355cd 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -199,9 +199,13 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 
 				self.scroll_offset = 0
 				self.filenames = filenames
-				self.infostring = ' %d' % len(self.filenames) # update the infostring
 				self.files = files
 
+				if self == self.fm.env.cwd:
+					for dir in self.files:
+						if dir.is_directory and dir.infostring == 'unknown':
+							dir.determine_infostring()
+
 				self._clear_marked_items()
 				for item in self.files:
 					if item.path in marked_paths:
@@ -219,8 +223,8 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 			else:
 				self.filenames = None
 				self.files = None
-				self.infostring = BAD_INFO
 
+			self.determine_infostring()
 			self.cycle_list = None
 			self.content_loaded = True
 			self.last_update_time = time()
diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py
index 94729b9a..4ebec3bc 100644
--- a/ranger/fsobject/fsobject.py
+++ b/ranger/fsobject/fsobject.py
@@ -156,6 +156,29 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 		"""Called by directory.mark_item() and similar functions"""
 		self.marked = bool(boolean)
 
+	def determine_infostring(self):
+		if self.is_device:
+			self.infostring = 'dev'
+		elif self.is_fifo:
+			self.infostring = 'fifo'
+		elif self.is_socket:
+			self.infostring = 'sock'
+		elif self.is_link:
+			self.infostring = '->'
+		elif self.is_directory:
+			try:
+				self.size = len(os.listdir(self.path))
+				self.infostring = " %d" % self.size
+				self.accessible = True
+				self.runnable = True
+			except OSError:
+				self.size = 0
+				self.infostring = BAD_INFO
+				self.accessible = False
+		elif self.is_file:
+			self.size = self.stat.st_size
+			self.infostring = ' ' + human_readable(self.size)
+
 	def load(self):
 		"""
 		reads useful information about the filesystem-object from the
@@ -188,40 +211,18 @@ class FileSystemObject(MimeTypeAware, FileManagerAware):
 		if self.accessible and os.access(self.path, os.F_OK):
 			self.exists = True
 			self.accessible = True
-
 			if os.path.isdir(self.path):
 				self.type = T_DIRECTORY
-				try:
-					self.size = len(os.listdir(self.path))
-					self.infostring = ' %d' % self.size
-					self.runnable = True
-				except OSError:
-					self.infostring = BAD_INFO
-					self.runnable = False
-					self.accessible = False
 			elif os.path.isfile(self.path):
 				self.type = T_FILE
-				self.size = self.stat.st_size
-				self.infostring = ' ' + human_readable(self.stat.st_size)
 			else:
 				self.type = T_UNKNOWN
-				if self.is_device:
-					self.infostring = 'dev'
-				elif self.is_fifo:
-					self.infostring = 'fifo'
-				elif self.is_socket:
-					self.infostring = 'sock'
-				else:
-					self.infostring = BAD_INFO
 
 		else:
-			if self.is_link:
-				self.infostring = '->'
-			else:
-				self.infostring = None
 			self.type = T_NONEXISTANT
 			self.exists = False
 			self.runnable = False
+		self.determine_infostring()
 
 	def get_permission_string(self):
 		if self.permissions is not None: