file delete cleanup

remove related data records when removing a file
Merge pull request #1021 from Remo/patch-42

file delete cleanup