Make FileCache upgrade more robust, fixes #2650

Basic problem is that username was guessed from the path instead of using the user value from the database.