Fixed event handling to handle case where we delete/rename pubspec.yaml or cache

Fixed #3018

review: @devoncarew

The case I wanted to handle here was when a folder would be renamed to "cache".
Then, there would be no simplification here.

I would be more comfortable if the cache folder was named ".pub-cache" and if renaming a file/folder to that name was not allowed.