Add error handling to the file cache upgrade

Error handling to prevent bad upgrades such as #2355 

@icewind1991 @karlitschek