hasse69 / rar2fs

FUSE file system for reading RAR archives
https://hasse69.github.io/rar2fs/
GNU General Public License v3.0
272 stars 25 forks source link

[FEATURE REQUEST] - Ability to delete inside rar #159

Open karibertils opened 3 years ago

karibertils commented 3 years ago

If possible, the ability to rm -rf folder to delete the underlying rar files would be very useful.

This might be difficult to implement if there are multiple files inside the rar archive. But at least in my case, if ANY files from inside the rar archive attempt delete, then it's acceptable to delete all the rar files.

This would need to be behind flag since that would be unexpected behaviour for those not aware of how it works.

hasse69 commented 3 years ago

And just deleting from the source folder is not enough?

karibertils commented 3 years ago

When using things like sonarr which can scan and upgrade media files to higher quality. It causes problem since sonarr cannot delete the old files. You can't scan the source folder since then it can't see the media files.

hasse69 commented 3 years ago

Got it. But how do you foresee this? I guess it is not the parent folder deletion you wish to trigger on but deletion of actual media files inside archives? So that if the archive holds only that single file it should delete the archive instead? Please describe the use case in detail or it will be hard to estimate amount of work needed.

karibertils commented 3 years ago

Yes exactly.

If I have multiple folders Video.XX which each contains a rar archive which has inside a single .mkv file. Through rar2fs all applications will see each of these folders as having a single .mkv file.

Sonarr can scan the folders and put upgraded .mkv into each folder where possible. Then afterwards when it tries to delete the previous .mkv it gets cannot remove 'XXXXX.mkv': operation not permitted. The idea was that at that time, instead of error, the system would accept removing the .mkv file and would also remove the underlying .rar archives.

But as I am typing this. I am thinking it would be much better actually, if rar2fs could at the time of delete, mkdir Video.XX/.deletedByRar2fs and move the underlying rar archive files to there. The mounted file system would hide everything that is in .deletedByRar2fs folders. So from the applications point of view the .mkv file was simply removed successfully and is now gone.

Then it would be impossible to have any kind of accidental data loss. But you could also get these kind of tools to work perfectly.

hasse69 commented 3 years ago

Doable I guess. But always moving deleted files to a trash-style folder might not be what you want either. But to allow deletion of an entire archive simply because a single file in it is "deleted", well I need to think about that one. From what I understand it would not be needed to cover your specific use-case anyway and it would appear more consistent not to allow it.

karibertils commented 3 years ago

Yes you understand correctly. For my use case, moving the archives for deleted files using trash style folder is just perfect. After thinking about it more, I see no reason for deleting the archives instead of just moving them. Looking forward to see if you can come up with a solution.

hasse69 commented 3 years ago

Unfortunately I cannot give you an ETA on this. I am rather busy right now and thus not able to look into it at the moment.

hasse69 commented 3 years ago

I was thinking, would it matter if actual archive is left as is and that only files get hidden from user?

karibertils commented 3 years ago

In my case it does not matter as long as there is some way to find which archive files were deleted. To be able to have some script "real" delete them periodically.

hasse69 commented 3 years ago

So a "fake" file residing under the rar2fs mount point as e.g. .~~some-archive.rar would be good enough to track what files that may be safely removed if it no longer provides any content?

karibertils commented 3 years ago

Sure, that's fine