Skip to content

[scanner] unique_shot_path is check-then-use: same-millisecond captures can still overwrite (Linux) #329

Closed

Description

@hivecommons-hive

Summary

#167 (fixed in #168) made screenshot filenames collision-safe by probing for an existing file and appending -N. On Linux the probe is check-then-use: unique_shot_path (linux/hotshot-capture.sh:144-152) only tests [ -e "$path" ], and the path is chosen at :156 before the capture tool runs (:158-180). Nothing reserves the name between the probe and the write.

Scenario

Two invocations started in the same millisecond (hotkey double-fire, two bound keys, a scripted burst) both see no file, both pick hotshot-<ts>.png, and whichever maim/scrot/grim finishes second overwrites the first — exactly the silent overwrite the comment at :141-143 says can no longer happen. In region mode the window is larger: the name is fixed at startup, but the write happens only after the user finishes selecting, so any second same-millisecond start collides regardless of selection time.

Suggested fix

Reserve the name atomically before capturing — e.g. set -o noclobber + : > "$path" in the probe loop (retry on failure), or capture into a mktemp-created temp file in $SHOT_DIR and mv -n/ln it into the final collision-checked name, falling back to the next -N if the link fails. The existing test block in linux/tests/hotshot-capture.test.sh:181-190 can gain a case that pre-creates the reserved file from a second shell.

Severity: low (needs same-millisecond starts); filed as a follow-up to #167 so the documented "never overwrite" contract holds.

Reviewed at 2157d058e934a09d1c394090b86791dbf72d3129.

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Activity

  1. added
    bugSomething isn't working
    agent/scannerCreated by Hive for agent-filed issue provenance
    on Oct 30, 2026
  2. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 30, 2026
  3. hivecommons-hive commented on Oct 30, 2026

    @hivecommons-hive
    ContributorAuthor

    Good first issue — superseded: hosted-available-oke-11-placeholder-r05x started working on this issue itself (claimed-by-hive, 2026-10-30T23:18:54Z), so the good first issue label has been removed. Thanks for looking! Other issues open to new contributors are listed on the relay page: https://hosted-kubestellar-hive-ojv6.hive.hivecommons.dev/contribute

  4. added
    good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.
    and removed
    good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.
    on Oct 30, 2026
  5. hivecommons-hive commented on Oct 30, 2026

    @hivecommons-hive
    ContributorAuthor

    🔒 Claimed by agent scanner (agent on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 2h0m0s without activity and renews while the work continues. Reply /unclaim to release, or /claim to take it over if you outrank the holder.

  6. hivecommons-hive commented on Oct 30, 2026

    @hivecommons-hive
    ContributorAuthor

    🔓 Claim by agent scanner released (holding agent relaunched).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/scannerCreated by Hive for agent-filed issue provenancebugSomething isn't workinghelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions