[PATCH 1/2] fix for non-completion of scan of external media, dev.laptop.org #10140
James Cameron
quozl at laptop.org
Mon Sep 6 20:58:14 EDT 2010
_recurse_dir() adds an instance of itself to the gobject idle loop once
for each directory on external media. The _pending_directories counter
is skewed if os.listdir() fails, which it would do if a directory was
not readable. This causes the scan to never complete; the journal keeps
showing the progress bar.
This patch catches and ignores exceptions encountered by os.listdir(),
allowing the counter to remain more consistent.
Also, the counter was not correctly tracked; there was a possibility the
ready signal would be emitted before all the instances of _recurse_dir()
had completed. This happened in testing.
The fix is to more strictly maintain the counter.
http://dev.laptop.org/ticket/10140
---
src/jarabe/journal/model.py | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 50e8dc1..c60349d 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -283,6 +283,7 @@ class InplaceResultSet(BaseResultSet):
def setup(self):
self._file_list = []
+ self._pending_directories += 1
self._recurse_dir(self._mount_point)
def stop(self):
@@ -321,7 +322,11 @@ class InplaceResultSet(BaseResultSet):
if self._stopped:
return
- for entry in os.listdir(dir_path):
+ try:
+ entries = os.listdir(dir_path)
+ except:
+ entries = []
+ for entry in entries:
if entry.startswith('.'):
continue
full_path = dir_path + '/' + entry
@@ -358,10 +363,9 @@ class InplaceResultSet(BaseResultSet):
logging.error('Error reading file %r: %s' % \
(full_path, traceback.format_exc()))
+ self._pending_directories -= 1
if self._pending_directories == 0:
self.setup_ready()
- else:
- self._pending_directories -= 1
def _get_file_metadata(path, stat):
client = gconf.client_get_default()
--
1.7.1
--zYM0uCDKw75PZbzx
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0002-journal-view-of-external-media-avoid-symlink-loops-0.patch"
More information about the Sugar-devel
mailing list