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

Deleting or restoring a trash item does not clean up empty dirs #9271

Closed
2 tasks done
butonic opened this issue May 28, 2024 · 7 comments
Closed
2 tasks done

Deleting or restoring a trash item does not clean up empty dirs #9271

butonic opened this issue May 28, 2024 · 7 comments
Assignees
Labels

Comments

@butonic
Copy link
Member

butonic commented May 28, 2024

When deleting or restoring an entry from the trash directory of a space we do not clean up empty nodes. This clutters the trash bin directory and slows down the listing because it has to glob all empty dirs. Which is even slower on NFS.

Another possibility to speed up listing the trashbin is to not shard the nodes in the trashbin dir and then cache the directory listing until the mtime of the ./trash directory changes. We could also do the caching with the sharded node layout by touching the trash directory, whenever a file is added or removed from the trash.

But removing empty dirs should be the first step:

@butonic butonic self-assigned this May 28, 2024
@butonic
Copy link
Member Author

butonic commented May 28, 2024

I don't know if it is worth a cli tool if

# find /home/jfd/.ocis/storage/users/spaces/so/me-admin-user-id-0000-000000000000/trash/* -type d -empty                           
/home/jfd/.ocis/storage/users/spaces/so/me-admin-user-id-0000-000000000000/trash/55/39/3d/dd
/home/jfd/.ocis/storage/users/spaces/so/me-admin-user-id-0000-000000000000/trash/66/ab/b3/ab

can be used to list all ampty dirs and

# find /home/jfd/.ocis/storage/users/spaces/so/me-admin-user-id-0000-000000000000/trash/* -type d -empty -delete

will even delete them recursively:

# find /home/jfd/.ocis/storage/users/spaces/so/me-admin-user-id-0000-000000000000/trash/* -type d -empty       

beware that leaving out the * in .../trash/* would delete the trash dir itself:

# mkdir -p /tmp/1/2/3/4     
# find /tmp/1 -type d -empty
/tmp/1/2/3/4
# find /tmp/1 -type d -empty -delete
# find /tmp/1 -type d -empty        
find: ‘/tmp/1’: Datei oder Verzeichnis nicht gefunden
# mkdir -p /tmp/1/2/3/4             
# find /tmp/1/* -type d -empty -delete
# find /tmp/1 -type d -empty          
/tmp/1

so to clean up all trash folders this should work:

find /var/lib/ocis/storage/users/spaces/*/*/trash/* -type d -empty # to be safe do a sanity check here
find /var/lib/ocis/storage/users/spaces/*/*/trash/* -type d -empty -delete

@butonic butonic changed the title Deleting or restoring a trash item dos not clean up empty dirs Deleting or restoring a trash item does not clean up empty dirs May 29, 2024
@butonic
Copy link
Member Author

butonic commented May 29, 2024

can be closed with the next reva bump, unless @d7oc thinks we should add a dedicated CLI command

@d7oc
Copy link
Contributor

d7oc commented May 29, 2024

I still vote for a CLI command. Not for myself, but I think our final approach is still to also address other users and as long as we don't want to document the workarounds presented here in our official documentation we need a CLI tool for them.

@butonic butonic removed their assignment May 31, 2024
@butonic
Copy link
Member Author

butonic commented May 31, 2024

@tbsbdr not for me to decide

@tbsbdr
Copy link
Contributor

tbsbdr commented Jun 17, 2024

👍 lets have a CLI

@micbar micbar added the Priority:p3-medium Normal priority label Jun 17, 2024
@micbar
Copy link
Contributor

micbar commented Jun 17, 2024

We will do the CLI in a follow up.

@micbar
Copy link
Contributor

micbar commented Jun 17, 2024

Closing here.

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

No branches or pull requests

4 participants