Reputation: 8004
I have created an online filesystem, based on php without using databases. It works well but there is one point annoying me:
Whenever I edit, move, rename files in a folder, only the direct parent (folder) gets a date (last edit) change. All other folders earlier in the tree keep their edit date...
Is there any way to make this last edit possible without editing each of the folders (which would mean a loss of performance for sure).
Im aware that a database solution would be nice, but the success of our file system is in the simplicity (no db required right now).
Thanks for your tips!
Upvotes: 0
Views: 152
Reputation: 22261
I am guessing that the files and directories in your "online"/virtual filesystem correspond one-to-one with files and directories in the underlying (server's) filesystem.
Normal POSIX filesystem semantics are that a directory's mtime is only updated when files are added, removed, or renamed in the directory. Making such a change in a directory does not cause an mtime change in any parent directories. Editing a file inside a directory also doesn't change the mtime of the directory, only the mtime of the file itself. (You did mention in your question that editing a file in a directory does cause the parent directory's modification time to be updated, but I think that's probably because you edit files by making a new copy and renaming it over the original.)
If you want the modification time of parent directories to change as well, and you want to record that information in the filesystem itself, you're doing to have to do it by manually touching each parent directory all the way up to the root. It's probably not going to be a big performance killer: you can use the touch
function which should amount to more or less just a single utime
system call per directory.
-Phil
Upvotes: 1