make sure we won't remove files if the database is not working
(cherry picked from commit 5dde6b52353b0cec1a24999c64cda2039e19c34a)