Skip to content

Commit

Permalink
+ remain unchange while file not modified
Browse files Browse the repository at this point in the history
  • Loading branch information
oluceps committed Nov 11, 2024
1 parent f20511d commit e954802
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cmd/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ pub fn edit(arg: EditSubCmd) -> eyre::Result<()> {
.map(SecBuf::<AgeEnc>::from)?
.decrypt(id_parsed.identity.as_ref())?
.inner();
let pre_hash = blake3::hash(buf.as_slice());

let edited_buf_encrypted = {
let edited = edit::edit(buf)?;

if blake3::hash(edited.as_bytes()) == pre_hash {
info!("file not edited");
return Ok(());
}

SecBuf::<Plain>::new(edited.into_bytes())
.encrypt(recips)?
.inner()
Expand Down

0 comments on commit e954802

Please sign in to comment.