|
|
|
@ -326,10 +326,10 @@ const ( |
|
|
|
|
dbLeveldb = "leveldb" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// hasPreexistingDb checks the given data directory whether a database is already
|
|
|
|
|
// PreexistingDatabase checks the given data directory whether a database is already
|
|
|
|
|
// instantiated at that location, and if so, returns the type of database (or the
|
|
|
|
|
// empty string).
|
|
|
|
|
func hasPreexistingDb(path string) string { |
|
|
|
|
func PreexistingDatabase(path string) string { |
|
|
|
|
if _, err := os.Stat(filepath.Join(path, "CURRENT")); err != nil { |
|
|
|
|
return "" // No pre-existing db
|
|
|
|
|
} |
|
|
|
@ -367,7 +367,7 @@ func openKeyValueDatabase(o OpenOptions) (ethdb.Database, error) { |
|
|
|
|
} |
|
|
|
|
// Retrieve any pre-existing database's type and use that or the requested one
|
|
|
|
|
// as long as there's no conflict between the two types
|
|
|
|
|
existingDb := hasPreexistingDb(o.Directory) |
|
|
|
|
existingDb := PreexistingDatabase(o.Directory) |
|
|
|
|
if len(existingDb) != 0 && len(o.Type) != 0 && o.Type != existingDb { |
|
|
|
|
return nil, fmt.Errorf("db.engine choice was %v but found pre-existing %v database in specified data directory", o.Type, existingDb) |
|
|
|
|
} |
|
|
|
|