]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Scan dir when service starts
authorDaira Hopwood <daira@jacaranda.org>
Fri, 17 Apr 2015 17:26:14 +0000 (18:26 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 17 Apr 2015 17:26:14 +0000 (18:26 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/drop_upload.py

index ea8d065fa564477922b7e71de55849e82955b78d..521b81488520b2febf4ae9eccaf2ee5fe8599fed 100644 (file)
@@ -75,12 +75,10 @@ class DropUploader(service.MultiService):
         self._notifier.watch(self._local_path, mask=mask, callbacks=[self._notify])
 
     def _check_db_file(self, childpath):
-        """_check_db_file returns True if the file must be uploaded.
-        """
+        # returns True if the file must be uploaded.
         assert self._db != None
         use_timestamps = True
         r = self._db.check_file(childpath, use_timestamps)
-        # XXX call r.should_check() ?
         return !r.was_uploaded()
 
     def _scan(self, localpath):
@@ -91,22 +89,20 @@ class DropUploader(service.MultiService):
         except EnvironmentError:
             raise(Exception("WARNING: magic folder: permission denied on directory %s" % (quoted_path,)))
         except FilenameEncodingError:
-            raise(Esception("WARNING: magic folder: could not list directory %s due to a filename encoding error" % (quoted_path,)))
+            raise(Exception("WARNING: magic folder: could not list directory %s due to a filename encoding error" % (quoted_path,)))
 
         for child in children:
             assert isinstance(child, unicode), child
             childpath = os.path.join(localpath, child)
             # note: symlinks to directories are both islink() and isdir()
             if os.path.isdir(childpath) and not os.path.islink(childpath):
-                metadata = tahoe_backup.get_local_metadata(childpath)
                 # recurse on the child directory
-                self.process(childpath)
+                self._scan(childpath)
             elif os.path.isfile(childpath) and not os.path.islink(childpath):
                 try:
-                    must_upload = self.check_db_file(childpath)
+                    must_upload = self._check_db_file(childpath)
                     if must_upload:
-                        pass # FIXME
-
+                        self._add_to_dequeue(childpath)
 
     def startService(self):
         self._db = backupdb.get_backupdb(self._dbfile, stderr)
@@ -114,6 +110,8 @@ class DropUploader(service.MultiService):
             # XXX or raise an exception?
             return Failure(Exception('ERROR: Unable to load magic folder db.'))
 
+        self._scan(self._local_path)
+
         service.MultiService.startService(self)
         d = self._notifier.startReading()
         self._stats_provider.count('drop_upload.dirs_monitored', 1)