Skip to content

Commit e824cd8

Browse files
committed
refactor(gmail): simplify attachment output + cache flow
1 parent 5ae8ac1 commit e824cd8

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

internal/cmd/gmail_attachment.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ func (c *GmailAttachmentCmd) Run(ctx context.Context, flags *RootFlags) error {
7373
}
7474
if dest.EnsureDefaultDir {
7575
// Ensure the config dir exists (so permissions are correct) before we write under it.
76-
if _, err := config.EnsureGmailAttachmentsDir(); err != nil {
77-
return err
76+
if _, ensureErr := config.EnsureGmailAttachmentsDir(); ensureErr != nil {
77+
return ensureErr
7878
}
7979
}
8080

@@ -206,9 +206,12 @@ func cachedRegularFile(outPath string, expectedSize int64) (cached bool, size in
206206
if expectedSize <= 0 {
207207
return false, 0, nil
208208
}
209-
st, err := os.Stat(outPath)
210-
if err != nil {
211-
return false, 0, nil
209+
st, statErr := os.Stat(outPath)
210+
if statErr != nil {
211+
if os.IsNotExist(statErr) {
212+
return false, 0, nil
213+
}
214+
return false, 0, statErr
212215
}
213216
if st.IsDir() {
214217
return false, 0, fmt.Errorf("outPath is a directory: %s", outPath)

0 commit comments

Comments
 (0)