trapexit / mergerfs-tools

Optional tools to help manage data in a mergerfs pool
ISC License
385 stars 44 forks source link

Extend mergerfs.dedup to folders #23

Open vejnar opened 8 years ago

vejnar commented 8 years ago

Hi,

mergerfs.dedup is very useful for files. But it doesn't take care of folders.

When a folder is created on multiple volumes, for instance to split the content of a folder among these volumes, and some of this content is removed, empty folders on some volume(s) remain(s). It would be great to remove these unnecessary empty folders.

Thanks. And thanks to develop mergerfs, it's great!

trapexit commented 8 years ago

You want to clean up directories on one drive that have data on others? The problem is that with path preserving those empty directories matter.

It can be done but it would have an effect on placement for path preserving.

Can also do a find -type d -empty -delete in the source paths.

vejnar commented 8 years ago

You want to clean up directories on one drive that have data on others?

Yes

The problem is that with path preserving those empty directories matter.

Could you please explain why? The folder exists with data on another drive. If it exists empty on another drive, is that not redundant?

Can also do a find -type d -empty -delete in the source paths.

No. That would remove also actual empty folder, not just redundant folder.

trapexit commented 8 years ago

Path preserving policies (generally) only consider drives with the path in question.

https://github.com/trapexit/mergerfs#policy-descriptions

If the directory is removed that drive would now not be considered and could break the intentions of the user given the policy.

I'm not saying that the feature isn't useful in so much that in a targeted way it can help clean up. Just that it could lead to issues if used without understanding that impact.

vejnar commented 8 years ago

Thanks for the explanation.

As an option to clean up, this would still be very useful IMHO.

If you plan to implement it, that would be appreciated. Otherwise please close this issue.

chapmanjacobd commented 1 year ago

removing nested empty folders is a bit complicated. This is the best solution I've found thus far:

yes | bfs -nohidden -type d -exec bfs -f {} -not -type d -exit 1 \; -prune -ok bfs -f {} -type d -delete \;

https://github.com/tavianator/bfs