Skip to content

Stray <input>.bak left behind (unnecessary when writing to a separate output file) #2

Description

@Sdaas

Problem

create_backup() always copies the input to ${INPUT_FILE}.bak (see decrypt-pdf:243-251). But every decryption strategy writes to a separate OUTPUT_FILE and never modifies the input in place, so this backup serves no purpose. Effects:

  • A <input>.bak is created next to the source on every run, cluttering the directory.
  • It is only logged under --verbose, so it appears silently by default.
  • It is never removed — it persists even after a failed decryption.

Observed while building a bulk wrapper around decrypt-pdf: every attempted/failed file left a stray <input>.pdf.bak that the wrapper had to detect and clean up.

Suggested fix

  • Only create a backup when the input is actually about to be modified in place (i.e. when the resolved OUTPUT_FILE == INPUT_FILE).
  • Otherwise skip it; or add --backup/--no-backup and remove it on success.
  • Either way, document the .bak side effect in the README / --help.

Activity

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions