summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO.org2
-rw-r--r--combox/events.py24
2 files changed, 23 insertions, 3 deletions
diff --git a/TODO.org b/TODO.org
index 741eadf..156d661 100644
--- a/TODO.org
+++ b/TODO.org
@@ -119,3 +119,5 @@
must do it through setup.py
*** DONE Write the combox monitor startup thingy
DEADLINE: <2015-01-29 Thu>
+** unit tests
+*** TODO unit test the NodeDirMonitor.on_modified method for the special Dropbox thing.
diff --git a/combox/events.py b/combox/events.py
index c0bc224..33ff9d9 100644
--- a/combox/events.py
+++ b/combox/events.py
@@ -293,6 +293,24 @@ class NodeDirMonitor(LoggingEventHandler):
def on_moved(self, event):
super(NodeDirMonitor, self).on_moved(event)
+ silo_node_dict = 'file_moved'
+
+ if (not self.shardp(event.src_path) and
+ not self.shardp(event.dest_path) and
+ not event.is_directory):
+ # The file moved is of no importance.
+ return
+ if (not self.shardp(event.src_path) and
+ self.shardp(event.dest_path) and
+ not event.is_directory):
+ # This is Dropbox specific.
+ #
+ # The file is renamed to a shard; so this the first time
+ # the shard appears in this node directory -- it is
+ # created.
+
+ silo_node_dict = 'file_created'
+
src_cb_path = cb_path(event.src_path, self.config)
dest_cb_path = cb_path(event.dest_path, self.config)
@@ -300,8 +318,8 @@ class NodeDirMonitor(LoggingEventHandler):
# means this path was moved on another computer that is
# running combox.
with self.lock:
- self.silo.node_set('file_moved', src_cb_path)
- num = self.silo.node_get('file_moved', src_cb_path)
+ self.silo.node_set(silo_node_dict, src_cb_path)
+ num = self.silo.node_get(silo_node_dict, src_cb_path)
if num != self.num_nodes:
return
else:
@@ -309,7 +327,7 @@ class NodeDirMonitor(LoggingEventHandler):
os.rename(src_cb_path, dest_cb_path)
except OSError, e:
print "Jeez, failed to rename path.", e
- self.silo.node_rem('file_moved', src_cb_path)
+ self.silo.node_rem(silo_node_dict, src_cb_path)
if not event.is_directory:
self.silo.remove(src_cb_path)