wileyyugioh / zotmoov

Zotero plugin to automatically move attachments and link them
GNU General Public License v3.0
351 stars 6 forks source link

More Options for Handling Duplicates #40

Open heymaad opened 3 weeks ago

heymaad commented 3 weeks ago

Currently, it creates a new pdf with -1 at the end. Would it be possible to have more customization, where:

  1. It would create a new file with " - 1" at the end as it does now
  2. Do not copy the file if it already exists
  3. Overwrite the previous copy, and show an error if overwrite fails

Please let me know if this sounds like a good feature to implement :)

wileyyugioh commented 2 weeks ago

It's definitely a possibility. Can you explain why specifically you want features 2 and 3?

The reason duplicates are handled the way they are now is to prevent files from accidentally being deleted when moved. For example Item A and Item B have pdfs that share the same filename, but contain different content. In the case of 2, Item B cannot be moved unless the filename is manually changed, and in the case of 3 Item A will be pointing to the wrong file.

danielvartan commented 2 weeks ago

I think @heymaad is referring to a duplicate behavior in zotmoov when attaching files from the source folder. Specifically, when attaching a file in Zotero using the menu option Zotmoov: Attach New File, the extension attaches two identical files to the reference.

This is really annoying. It makes the whole effort meaningless.

danielvartan commented 2 weeks ago

Here's a video showing the duplicate behavior.

https://www.loom.com/share/ecbcf031051240b8a73e2d6dc42a9fd4?sid=3b33e066-8209-4f34-bfb2-055ff08abc37

wileyyugioh commented 2 weeks ago

Oh wow. That is definitely a bug. What version of ZotMoov are you running? In the latest version (1.1.8) I made it so files are instantly linked when using the add menu option.

Also, the linked files are only deleted when you empty the trash.

danielvartan commented 2 weeks ago

I'm using the most recent version (1.1.8).

Oh wow. That is definitely a bug. What version of ZotMoov are you running? In the latest version (1.1.8) I made it so files are instantly linked when using the add menu option.

Also, the linked files are only deleted when you empty the trash.

wileyyugioh commented 2 weeks ago

Try 1.1.9. I think I identified the bug (a race condition between adding the file and the auto functionality).

danielvartan commented 2 weeks ago

Try 1.1.9. I think I identified the bug (a race condition between adding the file and the auto functionality).

It's working fine now! Thank you for all your hard work @wileyyugioh ! 🎉

wileyyugioh commented 2 weeks ago

Can you please try the latest prerelease and see if the problem is also fixed in this version? I changed how the bug was fixed under the hood and want to make sure it still works.

danielvartan commented 2 weeks ago

Can you please try the latest prerelease and see if the problem is also fixed in this version? I changed how the bug was fixed under the hood and want to make sure it still works.

Work like a charm. :)

danielvartan commented 1 day ago

Hi @wileyyugioh ,

I found the same duplicate behavior when attaching an EPUB to a reference.

EDIT: It's happening with PDFs too.

How to reproduce the error

System Info

wileyyugioh commented 1 day ago

Is this happening when you drag-drop an item? So it's not an issue with the add button is that right?

danielvartan commented 1 day ago

Is this happening when you drag-drop an item? So it's not an issue with the add button is that right?

Yes. It's not an issue with the add button.

wileyyugioh commented 1 day ago

@danielvartan Can you try 1.1.14. I think I found a race condition in the drag-drop code.

danielvartan commented 1 day ago

Just tried with the 1.1.14, as you suggested. All good!

Thank you for the quick response!