From 77aef9d1dfa597b51d8ad1b132ad9ee01c38d6e7 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 28 Apr 2015 23:33:37 +0100 Subject: [PATCH] Process directories unconditionally. Also pass overwrite=False and suppress ExistingChildError when creating a subdirectory, to avoid orphaning any existing directory. Signed-off-by: Daira Hopwood --- src/allmydata/frontends/drop_upload.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index 97bd5e9e..f765df3d 100644 --- a/src/allmydata/frontends/drop_upload.py +++ b/src/allmydata/frontends/drop_upload.py @@ -6,7 +6,7 @@ from twisted.internet import defer, reactor, task from twisted.python.failure import Failure from twisted.application import service -from allmydata.interfaces import IDirectoryNode, NoSuchChildError +from allmydata.interfaces import IDirectoryNode, NoSuchChildError, ExistingChildError from allmydata.util.fileutil import abspath_expanduser_unicode, precondition_abspath from allmydata.util.encodingutil import listdir_unicode, to_filepath, \ @@ -103,9 +103,8 @@ class DropUploader(service.MultiService): if islink: self.warn("WARNING: cannot backup symlink %s" % quote_local_unicode_path(childpath)) elif isdir: - must_upload = self._check_db_file(childpath) - if must_upload: - self._append_to_deque(childpath) + # process directories unconditionally + self._append_to_deque(childpath) # recurse on the child directory self._scan(childpath) @@ -183,8 +182,15 @@ class DropUploader(service.MultiService): def _add_dir(ignore, name): self._notifier.watch(to_filepath(path), mask=self.mask, callbacks=[self._notify], recursive=True) - d2 = self._parent.create_subdirectory(name) - d2.addCallback(lambda ign: self._log("created subdirectory %r" % (path,))) + d2 = self._parent.create_subdirectory(name, overwrite=False) + def _err(f): + f.trap(ExistingChildError) + self._log("subdirectory %r already exists" % (path,)) + d2.addCallbacks(lambda ign: self._log("created subdirectory %r" % (path,)), _err) + def _failed(f): + self._log("failed to create subdirectory %r due to %r" % (path, f)) + self._stats_provider.count('drop_upload.objects_failed', 1) + d2.addCallback(_failed) d2.addCallback(lambda ign: self._scan(path)) return d2 -- 2.45.2