fix bug tar <==> tar.gz
This commit is contained in:
parent
1627254cab
commit
617e49fa02
21
backup.py
21
backup.py
@ -241,6 +241,7 @@ class DataBase:
|
||||
""")
|
||||
|
||||
self.conn.row_factory = dict_factory
|
||||
# self.conn.set_trace_callback(print)
|
||||
|
||||
self.conn.commit()
|
||||
|
||||
@ -272,9 +273,25 @@ class DataBase:
|
||||
try:
|
||||
crypt_id_list.append(cursor.fetchone()['crypt_id'])
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
id = most_frequent(crypt_id_list)
|
||||
except ValueError:
|
||||
cursor.execute("""SELECT IFNULL(max(id) + 1, 0) as crypt_id FROM crypt""")
|
||||
return cursor.fetchone()['crypt_id']
|
||||
return most_frequent(crypt_id_list)
|
||||
params = {'id': id,
|
||||
'name': ', '.join([f"'{file['name']}'" for file in list_file]),
|
||||
'path': ', '.join([f"'{file['path']}'" for file in list_file])}
|
||||
cursor.execute("""SELECT 1 FROM files
|
||||
WHERE crypt_id={id}
|
||||
AND name NOT IN ({name})
|
||||
AND path NOT IN ({path})""".format(**params))
|
||||
neighbour = cursor.fetchall()
|
||||
if len(neighbour) > 0:
|
||||
cursor.execute("""SELECT IFNULL(max(id) + 1, 0) as crypt_id FROM crypt""")
|
||||
return cursor.fetchone()['crypt_id']
|
||||
else:
|
||||
return id
|
||||
|
||||
def exist(self, file):
|
||||
cursor = self.conn.cursor()
|
||||
@ -313,7 +330,7 @@ class DataBase:
|
||||
file_id += 1
|
||||
proceed = True
|
||||
if proceed:
|
||||
cursor.execute("""INSERT INTO crypt VALUES(?, ?)""", (crypt_id, compress_mode))
|
||||
cursor.execute("""INSERT OR IGNORE INTO crypt VALUES(?, ?)""", (crypt_id, compress_mode))
|
||||
self.conn.commit()
|
||||
return str(crypt_id).zfill(ZFILL)
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user