.pgp suffix

This commit is contained in:
Kumi 2023-01-09 17:45:22 +00:00
parent ef1537fcf2
commit 04f35d301f
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -19,7 +19,7 @@ if __name__ == "__main__":
raw = newfile.read_text()
encrypted: str = GPG().encrypt(raw, config.server.theirkey, sign=config.server.ourkey)
upfl = BytesIO(encrypted.encode())
uppath = Path(config.server.inpath) / f"{directory.name}_{newfile.name}"
uppath = Path(config.server.inpath) / f"{directory.name}_{newfile.name}.pgp"
with config.server.get_sftp_client() as sftp:
sftp.putfo(upfl, uppath)
@ -61,14 +61,17 @@ if __name__ == "__main__":
outpath = Path(directory.destination) / outfile
if outpath.suffix == ".pgp":
outpath = outpath.with_suffix("")
assert not outpath.exists()
outpath.write_text(decrypted)
if founddir.destinationbackup:
(Path(founddir.destinationbackup) / outfile).write_text(decrypted)
(Path(founddir.destinationbackup) / outpath.name).write_text(decrypted)
sftp.remove(rpath)
sftp.remove(rpath)
except Exception as e:
print(f"Something went wrong downloading files from the server: {e}")