From 6e8509a0bac9a9dc95648dd7de9bfaa0d5fa5550 Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Tue, 18 Apr 2017 15:57:07 +0200 Subject: [PATCH 1/2] Removed wierd line --- bin/Indexer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/Indexer.py b/bin/Indexer.py index 8c5bfcf9..22e3c9bc 100755 --- a/bin/Indexer.py +++ b/bin/Indexer.py @@ -26,8 +26,7 @@ TIME_WAIT = 1.0 #sec # return in bytes def check_index_size(indexname): global baseindexpath - the_index_name = indexname if indexname != "0" else "old_index" - the_index_name = join(baseindexpath, the_index_name) + the_index_name = join(baseindexpath, indexname) cur_sum = 0 for root, dirs, files in os.walk(the_index_name): cur_sum += sum(getsize(join(root, name)) for name in files) From b0f1cf84b7f4926a6bfa377a5054a1ad599f4eeb Mon Sep 17 00:00:00 2001 From: Mokaddem Date: Tue, 18 Apr 2017 16:02:22 +0200 Subject: [PATCH 2/2] remplaced usage of global variable by a function param --- bin/Indexer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/Indexer.py b/bin/Indexer.py index 22e3c9bc..e57b5f4d 100755 --- a/bin/Indexer.py +++ b/bin/Indexer.py @@ -24,8 +24,7 @@ from Helper import Process TIME_WAIT = 1.0 #sec # return in bytes -def check_index_size(indexname): - global baseindexpath +def check_index_size(baseindexpath, indexname): the_index_name = join(baseindexpath, indexname) cur_sum = 0 for root, dirs, files in os.walk(the_index_name): @@ -114,7 +113,7 @@ if __name__ == "__main__": if time.time() - last_refresh > TIME_WAIT: #avoid calculating the index's size at each message last_refresh = time.time() - if check_index_size(indexname) >= INDEX_SIZE_THRESHOLD*(1000*1000): + if check_index_size(baseindexpath, indexname) >= INDEX_SIZE_THRESHOLD*(1000*1000): timestamp = int(time.time()) print("Creating new index", timestamp) indexpath = join(baseindexpath, str(timestamp))