Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on_conflict: idempotent #277

Open
xdhmoore opened this issue Apr 19, 2023 · 2 comments
Open

on_conflict: idempotent #277

xdhmoore opened this issue Apr 19, 2023 · 2 comments
Milestone

Comments

@xdhmoore
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Often when doing a move what I want is to do trash if the two items are equal and rename_new if they aren't. I want to avoid adding a duplicate with a new name, but the destination directory isn't covered by the dedupe filter because it's not a source location.

Describe the solution you'd like
An on_conflict option that moves or copies the file only if there is not an equal file present. If speed demanded, filesize could be used as a heuristic instead of a full file sha1 or whatever. 90% of the time my files will have different sizes if they are unequal. Maybe a good name for this would be on_conflict: idempotent, cause multiple copies with the same file would have equal effect? Though I suppose technically a move would not be idempotent for the source directory...

Describe alternatives you've considered
I could choose rename_new, which would risk increasing bloat in my dest folder as new duplicate files come in. I could choose skip and risk missing the new files. I could somehow rig up my destination folder structure as a location and run a dedupe filter. But it's too big to realistically run a dedupe algorithm on all of it. There might be a way to break it into pieces and only execute the dedupe filter in a folder a file was added to.

@tfeldmann tfeldmann added this to the v3 milestone Nov 29, 2023
@tfeldmann
Copy link
Owner

Good idea, not sure about the name though. Maybe it's time for multiple parameters like:

on_conflict:
  - trash_if_equal  # or delete_if_equal
  - rename_new

@xdhmoore
Copy link
Contributor Author

xdhmoore commented Dec 2, 2023

Yeah, bad name. I guess one way to make it generic would be a list of matchers? First one that matches, do the child action:

on_conflict:
  - equal      # if files are equal
    - trash    
  - bigger    # if files are not equal and src file is bigger
    - someAction
  - smaller  # if none of the above and src file is smaller
    - someAction0
  - newer  # if none of the above and the src file is newer, idk i guess this will usually be true
    - someAction1
  - older
    - someAction2
  - python # custom matcher
    - someAction3

But that's increasing the scope...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants