From b60ef6b303c01039107cdf6433642cfb0b337557 Mon Sep 17 00:00:00 2001 From: ishaan Date: Thu, 20 Aug 2026 14:07:50 +0530 Subject: implement atomic writes --- cmd/eno/cobra_decrypt.go | 4 ++-- cmd/eno/cobra_encrypt.go | 4 ++-- internal/crud/cli_new_pass.go | 2 +- 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) -- cgit v1.3