From 4a72888c2e0d181913f4abb0c6b5a6f36e2864b1 Mon Sep 17 00:00:00 2001
From: Daira Hopwood <daira@jacaranda.org>
Date: Tue, 11 Aug 2015 15:09:56 +0100
Subject: [PATCH] Refactor uploader by inlining _add_file into
 _process._maybe_upload.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
---
 src/allmydata/frontends/magic_folder.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py
index abeaf6ea..f4f69ee8 100644
--- a/src/allmydata/frontends/magic_folder.py
+++ b/src/allmydata/frontends/magic_folder.py
@@ -287,10 +287,6 @@ class Uploader(QueueMixin):
         precondition(isinstance(path_u, unicode), path_u)
         d = defer.succeed(None)
 
-        def _add_file(encoded_name_u, version):
-            uploadable = FileName(path_u, self._client.convergence)
-            return self._upload_dirnode.add_file(encoded_name_u, uploadable, metadata={"version":version}, overwrite=True)
-
         def _add_dir(encoded_name_u):
             self._notifier.watch(to_filepath(path_u), mask=self.mask, callbacks=[self._notify], recursive=True)
             uploadable = Data("", self._client.convergence)
@@ -362,7 +358,9 @@ class Uploader(QueueMixin):
                     version = 0
                 else:
                     version += 1
-                d2 = _add_file(encoded_name_u, version)
+
+                uploadable = FileName(path_u, self._client.convergence)
+                d2 = self._upload_dirnode.add_file(encoded_name_u, uploadable, metadata={"version":version}, overwrite=True)
                 def add_db_entry(filenode):
                     filecap = filenode.get_uri()
                     s = os.stat(path_u)
-- 
2.45.2