]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Make _write_downloaded_file return the path of the destination file.
authorDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 17:39:54 +0000 (18:39 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 17:39:54 +0000 (18:39 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/magic_folder.py

index 44def8c92f22b67ca23dae6ef57abbedc27dc9bb..c654bca506293aff05c307f869023c5d559f77e9 100644 (file)
@@ -560,6 +560,8 @@ class Downloader(QueueMixin):
         # 4. Perform a file replacement with backup filename foo.backup,
         #    replaced file foo, and replacement file .foo.tmp. If any step of
         #    this operation fails, reclassify as a conflict and stop.
+        #
+        # Returns the path of the destination file.
 
         precondition(isinstance(path, unicode), path=path)
         path = fileutil.abspath_expanduser_unicode(path, base=base)
@@ -571,17 +573,16 @@ class Downloader(QueueMixin):
         fileutil.write(replacement_path, file_contents)
         os.utime(replacement_path, (now, now - cls.FUDGE_SECONDS))
         if is_conflict:
-            cls._rename_conflicted_file(path, replacement_path)
+            return cls._rename_conflicted_file(path, replacement_path)
         else:
             try:
                 fileutil.replace_file(path, replacement_path, backup_path)
+                return path
             except fileutil.ConflictError:
-                is_conflict = True
-                cls._rename_conflicted_file(path, replacement_path)
-        if is_conflict:
-            raise ConflictError("Conflict detected...")
+                return cls._rename_conflicted_file(path, replacement_path)
 
     @classmethod
     def _rename_conflicted_file(self, path, replacement_path):
         conflict_path = path + u".conflict"
         fileutil.rename_no_overwrite(replacement_path, conflict_path)
+        return conflict_path