-
Notifications
You must be signed in to change notification settings - Fork 28
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
Use references in restore_all
and purge_all
#54
Comments
Thanks a lot, I agree! A PR would be very welcome - I'd appreciate maintaining compatibility by using generics, i.e. |
Is it necessary to save |
What does 'Is it necessary to save |
I think the type of parameter affects the error handling. For example, we don't need field I'm confused with should |
I understand that the current API might be sub-optimal as it is affected by passing ownership - if references were passed, the API could be simplified. With that in mind, I think it would be possible to sketch this, and a PR for that would be very welcome. |
I have some questions about the doc of
Does it mean returning the number of restored files (like returning the number of bytes read/written in I/O) is completely unfeasible? But I do make it and the unit test for linux passed:
Actually I have finished all the work for the coming PR. Now I'm rebuilding them carefully to get a neat git commits record and a clear changelog. So there would be more commits after 2023-03-12 UTC+0 possibly. I feel sorry for asking you frequently before pulling request, but I have to make sure that I'm doing the effective work. Thanks. |
No worries. Since you are interested in neat commit histories, you might be interested in Stacked Git - I use it myself and it's super useful build a decent commit history from the get-go, which distributes the time it takes to do that through the development process. Also CC @ArturKovacs as the original author of the above quote. |
No. It just means that the order of let items = trash::list().unwrap();
let target_count = items.len();
if let Error::RestoreCollision{remaining_items, ..} = trash::restore_all(items) {
let restored_count = target_count - remaining_items.len()
} Obviously if |
The purpose of returning let items = trash::list().unwrap();
if let Error::RestoreCollison {restored, ..} = trash::os_limited::restore_all(&items) {
trash::os_limited::restore_all(items.iter().skip(restored + 1)).unwrap();
} I wrote the similar code in the unit test as mentioned above and it has passed. However, the error would be unfeasible if the restoration order isn't the provided order. It may lead the item that has been restored be restored again. This is the core of my question. |
Hey, @ArturKovacs , I wonder if #65 can be completed. Could you answer my question above? |
I wrote a comment under the PR. |
@oberblastmeister Would you like to close this issue? Because the behavior discussed was determined now. @Byron (off-topic) You forgot to update the version in README. |
restore_all
andpurge_all
should take references because they don't need the ownership ofTrashItem
s. This could reduce cloning when calling the functions.restore_all
might need an additional clone on aRestoreCollision
error because there isremaining_items
. My use case is specified in #53 .The text was updated successfully, but these errors were encountered: