From 754f99486bdc5f5d49394204a97c917da0c6b2d0 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 31 Aug 2015 17:53:36 +0100 Subject: [PATCH] Make _write_downloaded_file return the path of the destination file. Signed-off-by: Daira Hopwood --- src/allmydata/frontends/magic_folder.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 8eace2aa..0476373d 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -554,6 +554,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) @@ -565,14 +567,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: - cls._rename_conflicted_file(path, replacement_path) + 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 -- 2.45.2