From 2c7c011d68691ffe3aa7d308479e7204c2727617 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Fri, 6 Mar 2015 08:32:20 -0500 Subject: modded combox.file.node_path function. It has a third argument (boolean) which tells whether `cb_path' (the first argument) is a file or not. Updated the test for node_path function + code wherever node_path was used. modified: combox/events.py modified: combox/file.py modified: tests/file_test.py --- combox/events.py | 3 ++- combox/file.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'combox') 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) -- cgit v1.2.3