fix exception when files is removed (should fix #1755)