summaryrefslogtreecommitdiffstats
path: root/combox
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-09-29 14:15:49 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-09-29 14:15:49 -0400
commit54d70dad75387e0369c2b67dacff80d32d3cfc1e (patch)
treeb440706df3bd3c08fc6dd20ceeb5ab2a29a76c35 /combox
parent6171a67bb57f5ac10b43da785fe24aeb83fbd609 (diff)
[bug fix] fix for :b#2:
Now combox ignores tmp files created by editors. modified: TODO.org modified: combox/events.py modified: tests/events_test.py modified: tests/utils.py
Diffstat (limited to 'combox')
-rw-r--r--combox/events.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/combox/events.py b/combox/events.py
index 32bbc52..21df86e 100644
--- a/combox/events.py
+++ b/combox/events.py
@@ -56,6 +56,20 @@ class ComboxDirMonitor(LoggingEventHandler):
self.housekeep()
+ def tmp_file(self, file_path):
+ """Returns True if `file_path` is a tmp file."""
+
+ if file_path.endswith("~"):
+ return True
+ elif file_path.startswith(".#"):
+ return True
+ elif (file_path.startswith("#") and
+ file_path.endswith("#")):
+ return True
+ else:
+ return False
+
+
def housekeep(self):
"""Recursively traverses combox directory, discovers changes and updates silo and node directories.
@@ -100,7 +114,8 @@ class ComboxDirMonitor(LoggingEventHandler):
print fpath, "was modified. Updating DB and shards..."
split_and_encrypt(fpath, self.config)
self.silo.update(fpath)
- elif not self.silo.exists(fpath):
+ elif (not self.silo.exists(fpath)
+ and not self.tmp_file(fpath)):
# new file
print 'Adding new file', fpath, '...'
split_and_encrypt(fpath, self.config)
@@ -128,6 +143,11 @@ class ComboxDirMonitor(LoggingEventHandler):
def on_created(self, event):
super(ComboxDirMonitor, self).on_created(event)
+ if self.tmp_file(event.src_path):
+ # ignore tmp files.
+ print "Created tmp file", event.src_path, "...ignoring"
+ return
+
file_node_path = node_path(event.src_path, self.config,
not event.is_directory)
@@ -162,6 +182,11 @@ class ComboxDirMonitor(LoggingEventHandler):
def on_modified(self, event):
super(ComboxDirMonitor, self).on_modified(event)
+ if self.tmp_file(event.src_path):
+ # ignore tmp files.
+ print "Modified tmp file", event.src_path, "...ignoring"
+ return
+
if event.is_directory:
# do nothing
pass