Skip to content

Prevent Silent File Clobbering: Add Overwrite Flag & Existence Check for Output Files #19

@joshuayoes

Description

@joshuayoes

🧐 What & Why

screenshot and record_video overwrite existing files without warning, risking data loss.
An explicit opt-in to overwrite makes destructive actions deliberate.

🛠️ Proposal

  1. Before writing, execute fs.existsSync(absolutePath).
  2. If the file exists and force/overwrite flag is not supplied, throw:
    File already exists. Re-run with --overwrite to replace it.
    
  3. Add a force?: boolean parameter (default false) to screenshot, mirroring the flag already available on record_video.
  4. Thread this flag into command-line args (--force) where needed.

✅ Acceptance Criteria

  • Existing files are only overwritten when --overwrite (or JSON arg force: true) is passed.
  • Unit tests: overwrite denied vs. allowed.
  • README / CLI help updated with new flag.

⚠️ Backward Compatibility

Scripts relying on implicit overwrites must now pass --overwrite explicitly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions