From cf9c364c4be7f71a6a3c112253b07dfca1a11cbe Mon Sep 17 00:00:00 2001
From: Daira Hopwood <daira@jacaranda.org>
Date: Tue, 13 Oct 2015 15:56:31 +0100
Subject: [PATCH] Correct a call to did_upload_version in the downloader.

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

diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py
index e8572d05..904fc6fa 100644
--- a/src/allmydata/frontends/magic_folder.py
+++ b/src/allmydata/frontends/magic_folder.py
@@ -545,7 +545,9 @@ class Downloader(QueueMixin):
         d.addCallback(lambda ign: self._turn_deque())
         return d
 
-    def _process(self, item):
+    def _process(self, item, now=None):
+        if now is None:
+            now = time.time()
         (relpath_u, file_node, metadata) = item
         d = file_node.download_best_version()
         def succeeded(res):
@@ -555,11 +557,15 @@ class Downloader(QueueMixin):
             d2.addCallback(lambda result: self._write_downloaded_file(abspath_u, result, is_conflict=False))
             def do_update_db(written_abspath_u):
                 filecap = file_node.get_uri()
+                last_uploaded_uri = metadata.get('last_uploaded_uri', None)
+                last_downloaded_uri = filecap
+                last_downloaded_timestamp = now
                 written_pathinfo = get_pathinfo(written_abspath_u)
                 if not written_pathinfo.exists:
                     raise Exception("downloaded file %s disappeared" % quote_local_unicode_path(written_abspath_u))
 
-                self._db.did_upload_version(filecap, relpath_u, metadata['version'], written_pathinfo)
+                self._db.did_upload_version(relpath_u, metadata['version'], last_uploaded_uri,
+                                            last_downloaded_uri, last_downloaded_timestamp, written_pathinfo)
             d2.addCallback(do_update_db)
             # XXX handle failure here with addErrback...
             self._count('objects_downloaded')
-- 
2.45.2