Skip to content

Commit 3bc9586

Browse files
committed
Fix CLI error handling
I broke it completely in ad7d77b .
1 parent 50008f5 commit 3bc9586

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/lcp-decrypt/main.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ The 0123... string is the value you should pass in -userKey.
7070

7171
defer outFd.Close()
7272

73-
lcp.Decrypt(outFd, inFd, inStat.Size(), *userKeyHex, lcp.WithLogger(func(msg string) { log.Println(msg) }))
73+
if err := lcp.Decrypt(outFd, inFd, inStat.Size(), *userKeyHex, lcp.WithLogger(func(msg string) { log.Println(msg) })); err != nil {
74+
_ = os.Remove(outFilename) // ignore error here
75+
return fmt.Errorf("error decrypting file: %w", err)
76+
}
7477

7578
if err := outFd.Sync(); err != nil {
7679
return fmt.Errorf("error flushing output file: %w", err)

0 commit comments

Comments
 (0)