martymac / fpart

Sort files and pack them into partitions
https://www.fpart.org/
BSD 2-Clause "Simplified" License
230 stars 39 forks source link

Dirs containing only ignored files are not output when using -z option #14

Closed alexhunsley closed 5 years ago

alexhunsley commented 5 years ago

For example, suppose I run fpart -z against the following directory structure on disk, and I'm ignoring files called Thumbs.db:

directoryA/
    (no files)
directoryB/
    Thumbs.db

The partition files that result will have no mention of directoryB, only directoryA.

Should a folder containing only ignored files should be considered an empty folder, rather than a non-existent folder? Otherwise the existence of ignored files actually changes the output of fpart -z, which doesn't seem to make sense.

If this is expected behaviour, any chance of adding a flag that means "regard directories with only ignored files as empty directories"?

martymac commented 5 years ago

Hello Alex,

Good catch :)

This seems to me as the intended behaviour as the directory is not technically empty.

I wonder if such an option would be useful as that kind of situation should not arise very often: if you want to exclude all files from a directory, why would you want to include the directory itself? (also, it would be re-included once you decide to -at least- re-include one of those excluded files) That would probably complexify fpart code for a use case that is not very clear to me. Do you have an explicit use case for such an option ?

(meanwhile, an ugly workaround would be to create a .keepme file in such directories)

Best regards, Ganael.

alexhunsley commented 5 years ago

if you want to exclude all files from a directory, why would you want to include the directory itself?

It's legitimate to want to preserve empty directories where they exist. Sometimes the existence of a directory has significance, even if empty.

Btw, I don't want want to exclude all files from a directory, only some kinds. It just so happens that I have some directories in an Xcode project that are empty (beyond my control!) that must be preserved, but can contain a .DS_Store file, which is automatically created by Mac OS, and which I ignore.

In effect, I don't care about .DS_Store files and want to ignore them, but I can't do that currently, because doing that makes fpart unusable for me.

re: the .keepme file - is this something fpart already does? I'm not keen on that, though. I don't want my source data to change in order to cater to a tool that is used on it; doing that would mean the tool has become intrusive. It's affected my actual data. I don't want to get into writing scripts to put .keepme files into empty dirs.

Cheers, Alex

martymac commented 5 years ago

Hello Alex,

OK, I see, thanks for the use case and clarifications.

I'll see what can be done here... I am a bit busy right now, stay tuned :)

martymac commented 5 years ago

Hello Alex,

The following commit fixes the situation : https://github.com/martymac/fpart/commit/c317f9fe95c509314a10c9cb24c1227a662f6336

I now exclude files earlier, which have the following consequences :

IMHO, this is much clearer than what was made previously.

Thanks a lot for your report !

alexhunsley commented 4 years ago

Thanks so much for making this change!