diff options
| author | ishaan <contact@ishaan.cc> | 2026-08-20 14:07:50 +0530 |
|---|---|---|
| committer | ishaan <contact@ishaan.cc> | 2026-08-20 14:07:50 +0530 |
| commit | b60ef6b303c01039107cdf6433642cfb0b337557 (patch) | |
| tree | bb10c6583e9b7ec9cee987511c74f72e1ec4ba7a | |
| parent | 7caaf4c96d4f657d9193baf48e9745c9f68181c9 (diff) | |
implement atomic writes
| -rw-r--r-- | cmd/eno/cobra_decrypt.go | 4 | ||||
| -rw-r--r-- | cmd/eno/cobra_encrypt.go | 4 | ||||
| -rw-r--r-- | internal/crud/cli_new_pass.go | 2 | ||||
| -rw-r--r-- | internal/crud/cli_new_ssh.go | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/cmd/eno/cobra_decrypt.go b/cmd/eno/cobra_decrypt.go index 5f33ab5..8313014 100644 --- a/cmd/eno/cobra_decrypt.go +++ b/cmd/eno/cobra_decrypt.go @@ -56,7 +56,7 @@ var decryptCmd = &cobra.Command{ crypt.TryMlock(plaintext) defer clear(plaintext) - if err := os.WriteFile(output, plaintext, 0600); err != nil { + if err := utils.WriteFileAtomic(output, plaintext, 0600); err != nil { return err } @@ -78,7 +78,7 @@ var decryptCmd = &cobra.Command{ crypt.TryMlock(plaintext) defer clear(plaintext) - if err := os.WriteFile(output, plaintext, 0600); err != nil { + if err := utils.WriteFileAtomic(output, plaintext, 0600); err != nil { return err } diff --git a/cmd/eno/cobra_encrypt.go b/cmd/eno/cobra_encrypt.go index 1082bae..b1be494 100644 --- a/cmd/eno/cobra_encrypt.go +++ b/cmd/eno/cobra_encrypt.go @@ -67,7 +67,7 @@ var encryptCmd = &cobra.Command{ return err } - if err := os.WriteFile(output, encrypted, 0600); err != nil { + if err := utils.WriteFileAtomic(output, encrypted, 0600); err != nil { return err } @@ -87,7 +87,7 @@ var encryptCmd = &cobra.Command{ return err } - if err := os.WriteFile(output, encrypted, 0600); err != nil { + if err := utils.WriteFileAtomic(output, encrypted, 0600); err != nil { return err } diff --git a/internal/crud/cli_new_pass.go b/internal/crud/cli_new_pass.go index 2a8c2f4..2b01e13 100644 --- a/internal/crud/cli_new_pass.go +++ b/internal/crud/cli_new_pass.go @@ -153,7 +153,7 @@ func NewNotePassEdit(output, editorString string) error { perm = noteInfo.Mode().Perm() } - err = os.WriteFile(output, encrypted, perm) + err = utils.WriteFileAtomic(output, encrypted, perm) fmt.Println("New note saved at:", output) diff --git a/internal/crud/cli_new_ssh.go b/internal/crud/cli_new_ssh.go index 2a69223..797e769 100644 --- a/internal/crud/cli_new_ssh.go +++ b/internal/crud/cli_new_ssh.go @@ -226,7 +226,7 @@ func NewNoteSSHEdit(output string, defaultPubKeyBytes []byte, defaultPrivKeyPath perm = noteInfo.Mode().Perm() } - err = os.WriteFile(output, encrypted, perm) + err = utils.WriteFileAtomic(output, encrypted, perm) fmt.Println("New note saved at:", output) |