have users uploading files to their acc/s, and deleting from their acc/s
some files are long (eg songs etc).
to delete a file i was using
Code: Select all
while(file_exists($filename)) unlink($filename);which makes sense, can't delete something thats running.
next plan was to delete $filename entry from mysql tables and leave the file in the users folder. Have an admin script that would physicaly delete any 'dead files' from the users folders at a later date.
again works ok... unless-> say a user has uploaded a song, and whilst someone else is listening to that song, the user decides to delete, then changes his mind and uploads it again, it won't upload. Cause it can't replace the orginal which is streaming.
So... what i need to do is
1) check if a file is streaming
2) cancel all streams
3) flock() the file, (i think this is the function i'll use)
4) delete it.
5) eureeeka, i won't end up throwing laptop out of a dublin window upon some unsuspecting granny!
any solutions??