From: David Stainton <dstainton415@gmail.com>
Date: Tue, 14 Jul 2015 20:29:17 +0000 (-0700)
Subject: unlink old version of file from remote tahoe upload dirnode
X-Git-Url: https://git.rkrishnan.org/simplejson/components/flags/%22news.html/%3C?a=commitdiff_plain;h=a8507995f0805e3b4cb947ea270bed39767bef06;p=tahoe-lafs%2Ftahoe-lafs.git

unlink old version of file from remote tahoe upload dirnode
---

diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py
index 24ad5131..6169161b 100644
--- a/src/allmydata/frontends/magic_folder.py
+++ b/src/allmydata/frontends/magic_folder.py
@@ -280,15 +280,17 @@ class MagicFolder(service.MultiService):
                     # XXX upload if we didn't record our version in magicfolder db?
                     self._append_to_upload_deque(childpath)
                 else:
-                    # XXX handle case where we have a lesser version than what is in the collective directory
                     file_node, metadata = self._get_collective_latest_file(childpath)
                     if collective_version is None:
                         continue
                     if file_version > collective_version:
                         self._append_to_upload_deque(childpath)
                     elif file_version < collective_version:
-                        # XXX append file to upload queue
-                        pass
+                        # if a collective version of the file is newer than ours
+                        # we must download it and unlink the old file from our upload dirnode
+                        self._append_to_download_deque(childpath)
+                        # XXX where should we save the returned deferred?
+                        d = self._upload_dirnode.delete(childpath, must_be_file=True)
                     else:
                         # XXX same version. do nothing.
                         pass