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.row_factory = dict_factory
|
||||||
|
# self.conn.set_trace_callback(print)
|
||||||
|
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
@ -272,9 +273,25 @@ class DataBase:
|
|||||||
try:
|
try:
|
||||||
crypt_id_list.append(cursor.fetchone()['crypt_id'])
|
crypt_id_list.append(cursor.fetchone()['crypt_id'])
|
||||||
except TypeError:
|
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""")
|
cursor.execute("""SELECT IFNULL(max(id) + 1, 0) as crypt_id FROM crypt""")
|
||||||
return cursor.fetchone()['crypt_id']
|
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):
|
def exist(self, file):
|
||||||
cursor = self.conn.cursor()
|
cursor = self.conn.cursor()
|
||||||
@ -313,7 +330,7 @@ class DataBase:
|
|||||||
file_id += 1
|
file_id += 1
|
||||||
proceed = True
|
proceed = True
|
||||||
if proceed:
|
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()
|
self.conn.commit()
|
||||||
return str(crypt_id).zfill(ZFILL)
|
return str(crypt_id).zfill(ZFILL)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user