diff options
author | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-09-12 13:03:12 -0400 |
---|---|---|
committer | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-09-12 13:03:12 -0400 |
commit | e6ec8eb8e33542c8975f3ba1e96de7e2d43d221b (patch) | |
tree | a2944bf12e144513ab4ef858e1d96cb1d0010c52 | |
parent | c3b737ccb642aeec4f19e08c9c8185c63d1c7162 (diff) |
Introduced `node_store_moved_info' method in combox.silo.ComboxSilo class.
This method allows us to track old path and new path of the file which
is being renamed/moved.
modified: combox/silo.py
modified: tests/silo_test.py
-rw-r--r-- | combox/silo.py | 15 | ||||
-rw-r--r-- | tests/silo_test.py | 14 |
2 files changed, 27 insertions, 2 deletions
diff --git a/combox/silo.py b/combox/silo.py index 1b3eeac..b9ffc13 100644 --- a/combox/silo.py +++ b/combox/silo.py @@ -41,7 +41,7 @@ class ComboxSilo(object): ## things we need for housekeep the node directory. self.node_dicts = ['file_created', 'file_modified', 'file_moved', - 'file_deleted'] + 'file_deleted', 'file_moved_info'] # created the dicts if not already created. for ndict in self.node_dicts: @@ -169,6 +169,19 @@ class ComboxSilo(object): self.db.dadd(type_, (file_, num)) + def node_store_moved_info(self, src_path, dest_path): + """ + Update/create about file move. + + type_: expected type is 'file_moved_info'. + src_path: usually the source path of the file being moved. + dest_path: usually the destination path of the file being moved. + """ + self.reload() + with self.lock: + self.db.dadd('file_moved_info', (src_path, dest_path)) + + def node_get(self, type_, file_): """ Returns a number denoting the number of node directories in which the file_'s shard was created/modified/moved/deleted. diff --git a/tests/silo_test.py b/tests/silo_test.py index 174dfd5..66de6ba 100644 --- a/tests/silo_test.py +++ b/tests/silo_test.py @@ -106,7 +106,7 @@ class TestSilo(object): keys = silo.db.db.keys() node_dicts = ['file_created', 'file_modified', 'file_moved', - 'file_deleted'] + 'file_deleted', 'file_moved_info'] for ndict in node_dicts: assert ndict in keys @@ -202,6 +202,18 @@ class TestSilo(object): assert_equal(15, dict_file_deleted[self.LOREM]) + def test_csilo_node_store_moved_info(self): + """Tests node_store_moved_info method in ComboxSilo class. + """ + silo = ComboxSilo(self.config, self.silo_lock) + + src_path = self.LOREM + dest_path = self.LOREM_IPSUM + silo.node_store_moved_info(src_path, dest_path) + + assert_equal(dest_path, silo.node_get('file_moved_info', src_path)) + + def test_csilo_nodeget(self): """Tests node_get method in ComboxSilo class """ |