sigtop icon indicating copy to clipboard operation
sigtop copied to clipboard

Handle Filename Collisions for Recipients with Identical Names

Open micr0-dev opened this issue 5 months ago • 1 comments

what's the issue?

when you're exporting messages, attachments, or avatars from the signal desktop app, if two people have the same name, things can go wrong. you either get failed exports or it creates a bunch of unnecessary files.

the fix

so, i added a usedFilenames map to keep track of filenames during a single run. this way, it makes sure each filename is unique by adding a number to the end if needed (like "John Doe (2).txt").

what changed

  1. message export (cmdExportMessages)
    • now uses a map to track filenames.
    • ensures each filename is unique within the same run.
  2. attachment export (cmdExportAttachments)
    • also uses the map for filenames.
    • handles unique filenames for the whole export session.
  3. avatar export (cmdExportAvatars)
    • added the filename tracking here too.
    • guarantees unique filenames during the export.

why's this good?

  • no more export fails because of duplicate filenames.
  • won’t create unnecessary files when running multiple exports.

example

before:

sigtop: open John Doe.txt: file exists

after:

  • first "John Doe": John Doe.txt
  • second "John Doe": John Doe (2).txt

let me know if you need any tweaks or changes. thanks!

micr0-dev avatar Sep 12 '24 04:09 micr0-dev