From 04f35d301ff0cc37c1295bebb786af98f5f26b8d Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 9 Jan 2023 17:45:22 +0000 Subject: [PATCH] .pgp suffix --- daemon.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/daemon.py b/daemon.py index b1e14ad..919fa93 100644 --- a/daemon.py +++ b/daemon.py @@ -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}") \ No newline at end of file