From: David Stainton Date: Thu, 11 Jun 2015 21:24:06 +0000 (-0700) Subject: Change behavior upon finding missing files X-Git-Url: https://git.rkrishnan.org/%5B/frontends/%22news.html//%22%22.?a=commitdiff_plain;h=c6a122f34b6e99eb4c2f29a00f4d2d01a15ff29a;p=tahoe-lafs%2Ftahoe-lafs.git Change behavior upon finding missing files - Fix test test_magic_folder - Do not throw exception for missing files... - Check for entry in magic folder db; only write tahoe metadata deleted=true if magic folder db entry for file exists. --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 68bb792d..29fd238e 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -218,21 +218,20 @@ class MagicFolder(service.MultiService): # XXX todo: check if file exists in magic folder db # ... - if not self._db_file_is_uploaded(path): - return NoSuchChildError("not uploading non-existent file") + if not self._db.check_file_db_exists(path): + return None else: - # XXX ... u = Data("", self._convergence) - d2 = self._parent.add_file(name, u, overwrite=True) + d2 = defer.Succeed(None) def get_metadata(d): return self._parent.get_metadata_for(name) + d2.addCallback(get_metadata) def set_deleted(metadata): metadata['version'] += 1 metadata['deleted'] = True - return self._parent.set_metadata_for(name, metadata) - d2.addCallback(get_metadata) + return self._parent.add_file(name, u, overwrite=True, metadata=metadata) d2.addCallback(set_deleted) - return NoSuchChildError("not uploading non-existent file") + return d2 elif os.path.islink(path): raise Exception("symlink not being processed") if os.path.isdir(path): diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index 80e2c8e9..e6edd93d 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -305,8 +305,6 @@ class MagicFolderTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, Non self.notify(path, self.inotify.IN_CLOSE_WRITE) if temporary: - d.addCallback(lambda ign: self.shouldFail(NoSuchChildError, 'temp file not uploaded', None, - self.upload_dirnode.get, name_u)) d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_disappeared'), previously_disappeared + 1)) else: