I suggest you add a comment to the class stating the expected coordination between the file system and database.   Specifically, this code seems to depend on the database being the "source of truth" with the files being effectively external blob storage for the database.  So if a file is deleted out from under the database the whole system is corrupted.