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