Multithreading gzip

This commit is contained in:
lionel 2021-10-02 00:41:27 +02:00
parent 1776d7f15c
commit 479bab1d96

View File

@ -1,5 +1,5 @@
import re
import gzip
import mgzip as gzip
import tarfile
import sqlite3
from crypt import *
@ -26,10 +26,10 @@ class Backup:
print(f + " : ", human_size(size))
if size > tarball_size:
enc = crypt(compress(uri), self.key)
crypt_name = self.bdd.add([{'name': f, 'path': uri}], compress_mode="gz")
crypt_name = self.bdd.add([{'name': f, 'path': uri, 'size': size}], compress_mode="gz")
save(enc, os.path.join(self.save_location, crypt_name))
else:
files.append({'name': f, 'path': uri})
files.append({'name': f, 'path': uri, 'size': size})
elif os.path.isdir(uri):
self.recurse(uri)
if len(files) > 0:
@ -128,6 +128,7 @@ class DataBase:
id INTEGER PRIMARY KEY UNIQUE NOT NULL,
name TEXT,
path TEXT,
size TEXT,
crypt_id INTEGER,
CONSTRAINT files_crypt_FK FOREIGN KEY (crypt_id) REFERENCES crypt(id)
)
@ -149,7 +150,8 @@ class DataBase:
cursor.execute("""SELECT IFNULL(max(id) + 1, 0) FROM files""")
files_id = cursor.fetchone()[0]
for file in list_file:
cursor.execute("""INSERT INTO files VALUES(?, ?, ?, ?)""", (files_id, file['name'], file['path'], crypt_id))
cursor.execute("""INSERT INTO files VALUES(?, ?, ?, ?, ?)""",
(files_id, file['name'], file['path'], file['size'], crypt_id))
files_id += 1
cursor.execute("""INSERT INTO crypt VALUES(?, ?)""", (crypt_id, compress_mode))