Skip to content

Commit bf88a96

Browse files
committed
filesystem: use py2neo transaction to improve performance
1 parent af5b541 commit bf88a96

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

hooks/filesystem.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(self, parameters):
5959
self.inode_checksums = self.configuration.get('inode_checksums', False)
6060

6161
self.gfs = None
62+
self.tx = None
6263
self.counter = 0
6364
self.total_entries = 0
6465
self.time_last_update = 0
@@ -77,7 +78,12 @@ def capture_fs(self, event):
7778
self.walk_count(root)
7879
self.logger.info('Capturing filesystem')
7980
self.time_last_update = time.time()
81+
# start py2neo transaction
82+
# call self.graph.create() for each inode would be way too slow
83+
self.tx = self.graph.begin()
8084
root_inode = self.walk_capture(root)
85+
# commit transaction
86+
self.tx.commit()
8187
# signal the operating system hook
8288
# that the FS has been inserted
8389
# and send it the root_inode to build the relationship
@@ -110,7 +116,7 @@ def walk_capture(self, node):
110116
child_inode = self.walk_capture(subnode_abs)
111117
inode.children.add(child_inode)
112118
# update graph inode
113-
self.graph.create(inode)
119+
self.tx.create(inode)
114120
return inode
115121

116122
def process_new_file(self, event):

0 commit comments

Comments
 (0)