Doloops / mcachefs

mcachefs : Simple filesystem-based file cache based on fuse
64 stars 15 forks source link

mcachefs doesn't detect broken cached files. #14

Open hradec opened 5 years ago

hradec commented 5 years ago

I notice that, if mcachefs crashes during the download of a file (or the network goes down or you reboot the machine, etc), once mcachefs is mounted again, it will assume the incomplete file on the cache is OK and will NOT attempt to re-download it.

Since mcachefs has the size of the backend file in the metadata, a simple and fast way to fix this is to compare the actual size, and re-download the file in case the size is wrong.

As we're doing this check using the info in the metadata and the local cache file, it shouldn't create any noticeable slow down since there's no backend query until the fault is detected! It would also trigger re-download of backend modified files after a flush_metadata, if the size of the file changed.

This check could also be done for ctime and mtime to account for modified files of the same size.

what you guys reckon?