commit - e3ac3416ae8b8486d01a96d002ddfaa4915f0630
commit + e2af75a1cee6c654ec4c43d95353a31676cdd2a1
blob - 73060d5525eacde105f65f9b9a00e0691c1fdb31
blob + 89c830eb82347f3bfdb2750bedca4d5f8ccc7d24
--- CHANGELOG
+++ CHANGELOG
+Oct 21 2018 - 0.3
+ Add a params table where global parameters are stored
Oct 20 2018 - 0.3
add --force argument, add classical annexe files
Oct 18 2018 - 0.2
blob - 7e47e2712708a9d2cc809a340cb1d09117a0f037
blob + e04ecedf7600e59bdba1bbaff667e3de831c2676
--- yabitrot
+++ yabitrot
"""
Author : Vincent <vincent.delft@gmail.com>
-Version : 0.2
+Version : 0.3
Licence : BSD
Require : python >= 3.6
use sqlite3 DB embedded with python package
self.counter = 0
self.tts = time.time()
self.commitlimit = commitlimit
+ self.conn = None
+ self.cur = None
if os.path.exists(fpathname):
self.conn = sqlite3.connect(fpathname)
self.cur = self.conn.cursor()
tables = set(t for t, in self.cur.execute('SELECT name FROM sqlite_master'))
if 'cksum' not in tables:
self._create_db(fpathname)
+ if 'params' not in tables:
+ self._create_params(fpathname)
else:
self._create_db(fpathname)
+ self._create_params(fpathname)
def _create_db(self, fpathname):
self.conn = sqlite3.connect(fpathname)
timestamp REAL)""")
self.conn.commit()
+ def _create_params(self, fpathname):
+ if not self.conn:
+ self.conn = sqlite3.connect(fpathname)
+ if not self.cur:
+ self.cur = self.conn.cursor()
+ self.cur.execute("""CREATE TABLE params (
+ param TEXT PRIMARY KEY,
+ value TEXT
+ )""")
+ self.conn.commit()
+
def get_rec(self, inode):
self.cur.execute('SELECT mtime, hash, timestamp FROM cksum WHERE '
'inode=?', (inode,))
self.tts = time.time()
self.counter = 0
+ def set_param(self, param, value):
+ if not DRY_RUN:
+ print("para update")
+ self.cur.execute("""INSERT INTO params VALUES (?, ?)
+ ON CONFLICT(param) DO UPDATE SET value=? WHERE param=?
+ """, (param, value, value, param))
+ self.commit()
+
def close(self):
self.conn.commit()
self.conn.close()
total_size = 0
filesystemid = os.stat(rootpath).st_dev
log("Device ID:%s" % filesystemid)
+ DB.set_param("rootpath",os.path.join(os.getcwd(), rootpath))
+ DB.set_param("filesystemid", filesystemid)
analyze_tts = time.time()
for path, dummy, files in os.walk(rootpath):
for elem in files:
for excl_patt in excludes:
if fnmatch.fnmatch(elem, excl_patt):
to_skip = True
- if to_skip:
- continue
fpath = os.path.join(path, elem)
+ if to_skip:
+ if VERBOSE > 0:
+ log("Based on exclude rules, we skip: %s" % fpath)
+ continue
if VERBOSE > 1 and time.time() - analyze_tts > COMMIT_LIMIT:
log("working with:", fpath)
analyze_tts = time.time()