.pgp suffix
This commit is contained in:
parent
ef1537fcf2
commit
04f35d301f
1 changed files with 6 additions and 3 deletions
|
@ -19,7 +19,7 @@ if __name__ == "__main__":
|
||||||
raw = newfile.read_text()
|
raw = newfile.read_text()
|
||||||
encrypted: str = GPG().encrypt(raw, config.server.theirkey, sign=config.server.ourkey)
|
encrypted: str = GPG().encrypt(raw, config.server.theirkey, sign=config.server.ourkey)
|
||||||
upfl = BytesIO(encrypted.encode())
|
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:
|
with config.server.get_sftp_client() as sftp:
|
||||||
sftp.putfo(upfl, uppath)
|
sftp.putfo(upfl, uppath)
|
||||||
|
@ -61,14 +61,17 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
outpath = Path(directory.destination) / outfile
|
outpath = Path(directory.destination) / outfile
|
||||||
|
|
||||||
|
if outpath.suffix == ".pgp":
|
||||||
|
outpath = outpath.with_suffix("")
|
||||||
|
|
||||||
assert not outpath.exists()
|
assert not outpath.exists()
|
||||||
|
|
||||||
outpath.write_text(decrypted)
|
outpath.write_text(decrypted)
|
||||||
|
|
||||||
if founddir.destinationbackup:
|
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:
|
except Exception as e:
|
||||||
print(f"Something went wrong downloading files from the server: {e}")
|
print(f"Something went wrong downloading files from the server: {e}")
|
Loading…
Reference in a new issue