From 97f01af3589d40a8814f2d0f2c529f2ebcaa83dc Mon Sep 17 00:00:00 2001
From: David Stainton <dstainton415@gmail.com>
Date: Mon, 26 Oct 2015 15:14:21 +0100
Subject: [PATCH] Only compare dmd_last_downloaded_uri if it's not None

---
 src/allmydata/frontends/magic_folder.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py
index 89c26b0e..2d2fc89e 100644
--- a/src/allmydata/frontends/magic_folder.py
+++ b/src/allmydata/frontends/magic_folder.py
@@ -651,6 +651,7 @@ class Downloader(QueueMixin, WriteFileMixin):
 
     def _process(self, item, now=None):
         self._log("_process(%r)" % (item,))
+        is_conflict = False
         if now is None:
             now = time.time()
         (relpath_u, file_node, metadata) = item
@@ -682,15 +683,14 @@ class Downloader(QueueMixin, WriteFileMixin):
                 raise ConflictError("download failed: already conflicted: %r" % (relpath_u,))
             d.addCallback(fail)
         else:
-            if not self._db.check_file_db_exists(relpath_u):
-                is_conflict = False
-            else:
-                # XXX
+            if self._db.check_file_db_exists(relpath_u):
                 dmd_last_downloaded_uri = metadata.get('last_downloaded_uri', None)
                 local_last_downloaded_uri = self._db.get_last_downloaded_uri(relpath_u)
+                print "metadata %r" % (metadata,)
                 print "<<<<--- if %r != %r" % (dmd_last_downloaded_uri, local_last_downloaded_uri)
-                if dmd_last_downloaded_uri != local_last_downloaded_uri:
-                    is_conflict = True
+                if dmd_last_downloaded_uri is not None:
+                    if dmd_last_downloaded_uri != local_last_downloaded_uri:
+                        is_conflict = True
                 #dmd_last_uploaded_uri = metadata.get('last_uploaded_uri', None)
                 #local_last_uploaded_uri = ...
 
-- 
2.45.2