]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix path handling in Downloader._process.
authorDaira Hopwood <daira@jacaranda.org>
Mon, 31 Aug 2015 16:54:08 +0000 (17:54 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 31 Aug 2015 16:54:08 +0000 (17:54 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/magic_folder.py

index 0476373d67d3c32e6a989651e7938d61706d042d..16c5aa4031f7479f60ce088ad25e0b332e74add7 100644 (file)
@@ -519,17 +519,21 @@ class Downloader(QueueMixin):
         (name, file_node, metadata) = item
         d = file_node.download_best_version()
         def succeeded(res):
-            def do_update_db(result):
+            d2 = defer.succeed(res)
+            absname = abspath_expanduser_unicode(name, base=self._local_path_u)
+            d2.addCallback(lambda result: self._write_downloaded_file(absname, result, is_conflict=False))
+            def do_update_db(full_path):
                 filecap = file_node.get_uri()
-                s = os.stat(name)
+                try:
+                    s = os.stat(full_path)
+                except:
+                    raise(Exception("wtf downloaded file %s disappeared" % full_path))
                 size = s[stat.ST_SIZE]
                 ctime = s[stat.ST_CTIME]
                 mtime = s[stat.ST_MTIME]
                 self._db.did_upload_file(filecap, name, metadata['version'], mtime, ctime, size)
-            d2 = defer.succeed(res)
-            absname = abspath_expanduser_unicode(name)
-            d2.addCallback(lambda result: self._write_downloaded_file(absname, result))
             d2.addCallback(do_update_db)
+            # XXX handle failure here with addErrback...
             self._count('objects_downloaded')
             return d2
         def failed(f):