Skip to content

fix(gmail): combine --name with directory --out in attachment download#248

Closed
zerone0x wants to merge 1 commit intoopenclaw:mainfrom
zerone0x:fix/issue-222-attachment-name-flag
Closed

fix(gmail): combine --name with directory --out in attachment download#248
zerone0x wants to merge 1 commit intoopenclaw:mainfrom
zerone0x:fix/issue-222-attachment-name-flag

Conversation

@zerone0x
Copy link
Copy Markdown
Contributor

Summary

Fixes #222

When --out points to a directory (e.g. --out /tmp/), the --name flag was silently ignored and the directory path itself was used as the output file path. This caused two problems:

  1. --name ignored: --out /tmp/ --name invoice.pdf would write to /tmp/ instead of /tmp/invoice.pdf
  2. False cache hit: The cache check accepted directories as valid cached attachments because os.Stat succeeds on directories and Size() > 0 is always true for them

Changes

  • When --out resolves to an existing directory, combine it with --name (or the default filename) via filepath.Join
  • Add st.Mode().IsRegular() to cache validation in downloadAttachmentToPath so directories never produce false cache hits
  • Update --name help text to reflect that it works with directory --out values

Test Plan

  • go test ./... passes (all packages green)
  • New test: directory path with expectedSize == -1 is not treated as cache hit
  • New test: directory path with matching expectedSize > 0 is not treated as cache hit
  • make lint passes (0 issues)
  • make build succeeds

🤖 Generated with Claude Code (issue-hunter-pro)

When --out points to a directory, the --name flag was silently ignored
and the directory path itself was used as the output file path. This led
to confusing behavior where the cache check accepted the directory as a
valid cached attachment (since os.Stat succeeds on directories).

Now when --out is a directory, it is combined with --name (or the
default filename) via filepath.Join. The cache validation also requires
IsRegular() so directories can never produce false cache hits.

Fixes openclaw#222

Co-Authored-By: Claude <noreply@anthropic.com>
@steipete
Copy link
Copy Markdown
Collaborator

Landed on main as 2c34f8f (fixes #222). Thanks @zerone0x!

@steipete steipete closed this Feb 14, 2026
@zerone0x zerone0x deleted the fix/issue-222-attachment-name-flag branch February 14, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gmail attachment: --name flag silently ignored when --out is provided

2 participants