paolobenve / myphotoshare

MOVED TO GITLAB! --- A Web 2.0 Photo Gallery Done Right via Static JSON, Dynamic Javascript and a bit of php for sharing
15 stars 0 forks source link

Re-scan an album content when album.ini content has changed. #73

Closed pmetras closed 6 years ago

pmetras commented 6 years ago

Currently, when the content of the album.ini file containing extra-metadata is modified but the photos/videos in the album are not, the changes are not detected and the scanner does not process the album content.

How to detect when album.ini file has been modified?

Can we compare the modification date of album.ini with a file for that album in the cache directory?

paolobenve commented 6 years ago

my last commit solved this issue, didn't it?

pmetras commented 6 years ago

Sorry, I did not see you message when I created this issue. I'll test it tonight.

paolobenve commented 6 years ago

closing, seems ok, reopen it if not ok

paolobenve commented 6 years ago

A check is missing on album.ini removed.

I think the way is adding a boolean key to the album json file, so that the code can see that it was there and has disappeared

pmetras commented 6 years ago

Instead of a boolean in the JSON file, the timestamp of the file can be used to manage all the cases. If the album.ini file timestamp is different from the one in JSON, either because of change or because inexistant, the scanner should process all the files in the directory.

paolobenve commented 6 years ago

you mean that instead of a boolean, a timestamp has to be added to album json file?

pmetras commented 6 years ago

Yes.

paolobenve commented 6 years ago

well, a remotion of album.ini should make the dir modification date change, and that should make invalid the json file. It I'm right, nothing has to be added to the json file

pmetras commented 6 years ago

Usually, it's correct. But there are trends in the linux world to mount filesystems with noatime and nodiratime flags set to have performance gain or when using a FLASH storage to reduce writes. This would break your proposal. You can select the safe path (change in JSON) or the mostly safe one (check directory atime) depending on how you want the users to manage it. If it's well documented, the mostly safe can do because album.ini files are rarely deleted.

First Google results on the subject:

paolobenve commented 6 years ago

atime is the access time, it's hasn't anything to do with it, the scanner checks mtime, which I think is always set on all filesystem.

https://stackoverflow.com/questions/3620684/directory-last-modified-date: "The mtime (modification time) on the directory itself changes when a file or a subdirectory is added, removed or renamed".

It does not seem that there is need to add anything to json file

pmetras commented 6 years ago

OK. Great!