Skip to content

Removed code to handle GenerateUniqueName bug #9397

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

Merged
merged 4 commits into from
Jun 19, 2022

Conversation

puppetsw
Copy link
Contributor

Resolved / Related Issues
Items resolved / related issues by this PR.

Details of Changes
Add details of changes here.

  • Removed code that doesn't seem necessary anymore as dragging from zip respects the GenerateUniqueName enum. This also fixes the issue with dragging from a browser.

Validation
How did you test these changes?

  • Built and ran the app

Screenshots (optional)
Add screenshots here.

@puppetsw
Copy link
Contributor Author

@gave92 Did you want to have a look at this one? I believe you added the original code to handle the bug that was there. From my testing it seems no longer necessary?

@gave92 gave92 marked this pull request as ready for review June 12, 2022 19:00
@gave92
Copy link
Member

gave92 commented Jun 12, 2022

Yep I'll check though I can't remember exactly what the problem was here. Like extracting the same file twice from .zip.

@gave92
Copy link
Member

gave92 commented Jun 18, 2022

Ok I was able to reproduce the issue. Steps are:

  • Open a .zip file in windows explorer
  • Drag a file from the archive and drop it in a folder where an item with the same name already exists
  • The existing file will get overwritten even if "generate new name" option was selected

Not sure what to do about that but sure I have to learn to write better comments -.-

@puppetsw
Copy link
Contributor Author

puppetsw commented Jun 19, 2022

Ok I was able to reproduce the issue. Steps are:

  • Open a .zip file in windows explorer
  • Drag a file from the archive and drop it in a folder where an item with the same name already exists
  • The existing file will get overwritten even if "generate new name" option was selected

Not sure what to do about that but sure I have to learn to write better comments -.-

Ah yeah, the GenerateUniqueName is completely ignored.

I'll have another look and see if there is a possible workaround, but if you weren't able to find anything I don't think I will. If that's the case do you want me to just update the comment with this PR or close it out?

I wonder if it's because the File object from the dragged zip file doesn't contain a path, so it isn't able to compare correctly.

@puppetsw
Copy link
Contributor Author

A bit of a hacky solution. What are your thoughts @gave92 ?

@gave92
Copy link
Member

gave92 commented Jun 19, 2022

A bit of a hacky solution. What are your thoughts @gave92?

I don't like it 😜 but yeah it seems the only solution 👍

I wonder if it's because the File object from the dragged zip file doesn't contain a path, so it isn't able to compare correctly.

Path being empty appears not to be the only factor. When dragging files from Phone storage, path is also empty but GenerateUniqueName works fine.

@gave92
Copy link
Member

gave92 commented Jun 19, 2022

@puppetsw do you mind if I tweak your solution slightly?

@puppetsw
Copy link
Contributor Author

@puppetsw do you mind if I tweak your solution slightly?

Yeah go for it.

@gave92
Copy link
Member

gave92 commented Jun 19, 2022

Done, I've made changes so:

  • There's no risk of a "race condition", e.g. of a file appearing between the call to TryGetItemAsync and the actual copy
  • Avoids using StorageFolder methods as they may not work if the destination folder is another zip file or some other special location
  • Should be a little faster if there is no conflict

@gave92 gave92 self-requested a review June 19, 2022 16:02
@puppetsw
Copy link
Contributor Author

Looks much better now. I didn’t consider the race condition. Thanks for your help and input.

@gave92 gave92 added ready to merge Pull requests that are approved and ready to merge and removed needs - code review labels Jun 19, 2022
@yaira2 yaira2 merged commit 446d7a9 into files-community:main Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Pull requests that are approved and ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File not showing up after renaming from conflict dialog (via drag & drop)
3 participants