add bzip2 compress support for path type files

This commit is contained in:
2021-09-12 12:13:59 +08:00
parent 875e39a2c9
commit 8249473755
7 changed files with 207 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ from game_backuper.hashl import sha512
from shutil import copy2
from game_backuper.filetype import FileType
from os import remove
from game_backuper.compress import supported_exts
File = namedtuple('File', ['id', 'file', 'size', 'program', 'hash', 'type'])
@@ -74,3 +75,15 @@ def remove_dirs(loc: str):
except Exception:
remove_dirs(i)
remove(loc)
def remove_compress_files(loc: str, prog: str, name: str, ext: str = None):
exts = supported_exts.copy()
if ext is not None:
exts.remove(ext)
exts.append('')
for i in exts:
f = loc + i
if exists(f) and isfile(f):
remove(f)
print(f'{prog}: Removed {f}({name})')