I'm working on a document management application on LAMP/php that lets you add and delete PDFs to our server. It works great, except for one nagging issue - the files you upload Monday might be gone Tuesday, and I can't diagnose why. it seems like the entire directory is getting deleted - my suspicion is that somewhere an incomplete string is getting passed to an unlink or something, but I've disabled every line of code I can find that removes files from the server and I'm still having trouble. How do I go about diagnosing the cause of these random disappearing files? Are there any utilities I can use to log any attempted removal of or changes to a file or directory?
idealy you'd want to find your bug...
find codebase/ -type f -exec grep -il "unlink" '{}' \;
alertativley if you want a hacky fix, update your apache user to have a umask that would enable it to create files, but not delete them...
sed -i 's/^\(start|[a-z|-]*)\)/\1\n umask 0222/' `which apachectl`
also this would generate permission dennied errors in the error log...