Skip to content

Failed clipboard writes leave .tmp files in the sync folder #32

Description

@offbyonebit

Severity: medium
Type: robustness
Location: clipsync/clipboard.pyClipboardSync._write_file() (~line 710), _write_image_file() (~line 790)

Problem: Both methods write to a .tmp sibling and then tmp.replace(path). If the replace fails with a non-PermissionError, or after the retry loop exhausts, the exception propagates and the temporary file is left behind. Syncthing may then sync the partial .tmp file to peers.

Suggested fix: Wrap the replace loop in a try/finally (or context manager) that deletes the temporary file whenever the write does not complete successfully.


Filed from a full-source audit of the repo (2026-07-29). Reported by the audit but not independently confirmed - verify the cited code before acting on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditFound in the 2026-07 code auditbugSomething isn't workingseverity:mediumDegraded behaviour or edge case

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions