summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--combox/events.py3
-rw-r--r--combox/file.py5
-rw-r--r--tests/file_test.py6
3 files changed, 9 insertions, 5 deletions
diff --git a/combox/events.py b/combox/events.py
index 6b17dcf..d3d845a 100644
--- a/combox/events.py
+++ b/combox/events.py
@@ -130,7 +130,8 @@ class ComboxDirMonitor(LoggingEventHandler):
super(ComboxDirMonitor, self).on_created(event)
self.silo_update()
- file_node_path = node_path(event.src_path, self.config)
+ file_node_path = node_path(event.src_path, self.config,
+ not event.is_directory)
if event.is_directory and (not path.exists(file_node_path)):
# creates a corresponding directory at the node dirs.
diff --git a/combox/file.py b/combox/file.py
index fe5c58e..1606da5 100644
--- a/combox/file.py
+++ b/combox/file.py
@@ -69,15 +69,16 @@ def cb_path(node_path, config):
return file_cb_path
-def node_path(cb_path, config):
+def node_path(cb_path, config, isfile):
"""Returns abs. path of file (in node dir.) given the cb_path (combox dir. path).
If cb_path is a file, it returns the path to its first shard in
the first node directory.
+ isfile: True if cb_path is a file.
"""
- if path.isfile(cb_path):
+ if isfile:
# partition function is used to remove the `.shard.N' from the
# file name.
rel_file_path = relative_path(cb_path, config)
diff --git a/tests/file_test.py b/tests/file_test.py
index 0e19e60..8065ff7 100644
--- a/tests/file_test.py
+++ b/tests/file_test.py
@@ -145,14 +145,16 @@ class TestFile(object):
test_file_shard_0)
assert test_file_shard_0_abspath == node_path(self.TEST_FILE,
- self.config)
+ self.config,
+ isfile=True)
foo_dir = path.join(self.config['combox_dir'], 'foo')
foo_nodedir = path.join(get_nodedirs(self.config)[0],
'foo')
- assert foo_nodedir == node_path(foo_dir, self.config)
+ assert foo_nodedir == node_path(foo_dir, self.config,
+ isfile=False)
def test_rmpath(self):