2033: Bug(FS): Consider empty pre-created directory as unexisting DB r=curquiza a=ManyTheFish

When the database directory was pre-created we were considering that DB is invalid, we are now accepting to create a database in it.


Co-authored-by: Maxime Legendre <maximelegendre@mbp-de-maxime.home>
This commit is contained in:
bors[bot] 2021-12-21 15:12:07 +00:00 committed by GitHub
commit 0e2f6ba1b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -167,8 +167,12 @@ impl IndexControllerBuilder {
let db_exists = db_path.as_ref().exists(); let db_exists = db_path.as_ref().exists();
if db_exists { if db_exists {
// Directory could be pre-created without any database in.
let db_is_empty = db_path.as_ref().read_dir()?.next().is_none();
if !db_is_empty {
versioning::check_version_file(db_path.as_ref())?; versioning::check_version_file(db_path.as_ref())?;
} }
}
if let Some(ref path) = self.import_snapshot { if let Some(ref path) = self.import_snapshot {
log::info!("Loading from snapshot {:?}", path); log::info!("Loading from snapshot {:?}", path);