]> git.treefish.org Git - photosort.git/blobdiff - src/bunch.py
relax cache check
[photosort.git] / src / bunch.py
index 228131a9e1ec5e6b8157f86813b9fbffceb15634..5bc3eddc5ca49f59f2588e86d85a026911a2d057 100644 (file)
@@ -1,4 +1,5 @@
 import logging
 import logging
+import os
 import time
 import threading
 
 import time
 import threading
 
@@ -13,7 +14,7 @@ class Bunch:
             self.migrator = migrator
             self.cleanup = cleanup
 
             self.migrator = migrator
             self.cleanup = cleanup
 
-    def __init__(self, idx, cfg):
+    def __init__(self, idx, cache_dir, cfg):
         self._idx = idx
         source_idx = 1
         self._sources = []
         self._idx = idx
         source_idx = 1
         self._sources = []
@@ -23,7 +24,8 @@ class Bunch:
                     source_idx,
                     DirTrigger(src_dir_cfg['path'], src_dir_cfg['cool_time'],
                                src_dir_cfg['max_time']),
                     source_idx,
                     DirTrigger(src_dir_cfg['path'], src_dir_cfg['cool_time'],
                                src_dir_cfg['max_time']),
-                    Migrator(src_dir_cfg['path'], cfg['dst_dir']['path']),
+                    Migrator(src_dir_cfg['path'], cfg['dst_dir']['path'],
+                             os.path.join(cache_dir, "%d.db" % idx)),
                     src_dir_cfg['cleanup']
                 )
             )
                     src_dir_cfg['cleanup']
                 )
             )
@@ -40,6 +42,8 @@ class Bunch:
         logging.info("Stopping bunch #%d...", self._idx)
         self._stop = True
         self._worker_thread.join()
         logging.info("Stopping bunch #%d...", self._idx)
         self._stop = True
         self._worker_thread.join()
+        for src in self._sources:
+            src.migrator.close()
         logging.info("Stopped bunch #%d.", self._idx)
 
     def is_running(self):
         logging.info("Stopped bunch #%d.", self._idx)
 
     def is_running(self):