From 594de028e81ce8afdc536fca4844b4c14fe9f6d0 Mon Sep 17 00:00:00 2001 From: David Stainton Date: Thu, 11 Jun 2015 14:24:06 -0700 Subject: [PATCH] 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. --- src/allmydata/frontends/magic_folder.py | 13 ++++++------- src/allmydata/test/test_magic_folder.py | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) 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: -- 2.45.2