summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-05-23 05:23:00 +0200
committerhut <hut@lavabit.com>2010-05-23 05:23:00 +0200
commit50f7b49da62240cf7a1f5dcd5ac0859f6453c093 (patch)
tree6a2cc4cf3ab26ccd0c9abc17bdb75596d8ae447b /ranger
parentd5d0dee9832cab5dbac7686f3ec7ab0c80ecab16 (diff)
downloadranger-50f7b49da62240cf7a1f5dcd5ac0859f6453c093.tar.gz
fsobject.directory: optimize loop in load_bit_by_bit
Diffstat (limited to 'ranger')
-rw-r--r--ranger/fsobject/directory.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index d86c86aa..f1bcd9a3 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -184,31 +184,34 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 				marked_paths = [obj.path for obj in self.marked_items]
 
 				files = []
+				disk_usage = 0
 				for name in filenames:
 					try:
 						file_lstat = os_lstat(name)
-						if S_ISLNK(file_lstat.st_mode):
+						if file_lstat.st_mode & 0o170000 == 0o120000:
 							file_stat = os_stat(name)
 						else:
 							file_stat = file_lstat
 						stats = (file_stat, file_lstat)
-						is_a_dir = S_ISDIR(file_stat.st_mode)
+						is_a_dir = file_stat.st_mode & 0o170000 == 0o040000
 					except:
 						stats = None
 						is_a_dir = False
 					if is_a_dir:
 						try:
 							item = self.fm.env.get_directory(name)
+							item.load_if_outdated()
 						except:
 							item = Directory(name, preload=stats,
 									path_is_abs=True)
+							item.load()
 					else:
 						item = File(name, preload=stats, path_is_abs=True)
-					item.load_if_outdated()
+						item.load()
+						disk_usage += item.size
 					files.append(item)
 					yield
-
-				self.disk_usage = sum(f.size for f in files if f.is_file)
+				self.disk_usage = disk_usage
 
 				self.scroll_offset = 0
 				self.filenames = filenames