change tar archive hashing to sha256
This commit is contained in:
@@ -9,8 +9,7 @@ import subprocess
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
|
||||
VERSION = "0.1.0"
|
||||
|
||||
VERSION = "0.1.1"
|
||||
|
||||
class TB:
|
||||
def __init__(self, options):
|
||||
@@ -130,7 +129,7 @@ class TB:
|
||||
self.backup_source,
|
||||
]
|
||||
print(command)
|
||||
md5 = hashlib.md5()
|
||||
sha256 = hashlib.sha256()
|
||||
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=fp_log)
|
||||
|
||||
if self.do_gpg:
|
||||
@@ -152,7 +151,7 @@ class TB:
|
||||
break
|
||||
print(f"{i} Mb", end="\r")
|
||||
i += 1
|
||||
md5.update(chunk)
|
||||
sha256.update(chunk)
|
||||
fp.write(chunk)
|
||||
if self.do_gpg:
|
||||
os.close(pwpipe_r)
|
||||
@@ -163,10 +162,10 @@ class TB:
|
||||
print(f"\nWrote {os.path.join(self.base_folder, self.backup_folder,self.tar_file)}")
|
||||
print(f"Log file {os.path.join(self.base_folder, self.backup_folder,self.tar_file+'.log')}")
|
||||
with open(
|
||||
os.path.join(self.base_folder, self.backup_folder, self.tar_file + ".md5"),
|
||||
os.path.join(self.base_folder, self.backup_folder, self.tar_file + ".sha256"),
|
||||
"w",
|
||||
) as fp_md5:
|
||||
fp_md5.write(f"{md5.hexdigest()} {self.tar_file}\n")
|
||||
) as fp_sha256:
|
||||
fp_sha256.write(f"{sha256.hexdigest()} {self.tar_file}\n")
|
||||
if not success:
|
||||
with open(os.path.join(self.base_folder, self.backup_folder, self.tar_file + ".log")) as f:
|
||||
print(f.read(), end="")
|
||||
|
||||
Reference in New Issue
Block a user