Fix opening the database before folder is created
These conditions should be inverted