Provide filesystem for JSON store

This commit is contained in:
Ingo Oppermann
2024-02-12 09:56:40 +01:00
parent 00c5ad3883
commit 85b2c9b53d

View File

@@ -34,13 +34,13 @@ func main() {
os.Exit(1) os.Exit(1)
} }
if err := doMigration(logger, configstore); err != nil { if err := doMigration(logger, diskfs, configstore); err != nil {
logger.Error().WithError(err).Log("Migration failed") logger.Error().WithError(err).Log("Migration failed")
os.Exit(1) os.Exit(1)
} }
} }
func doMigration(logger log.Logger, configstore cfgstore.Store) error { func doMigration(logger log.Logger, fs fs.Filesystem, configstore cfgstore.Store) error {
if logger == nil { if logger == nil {
logger = log.New("") logger = log.New("")
} }
@@ -94,14 +94,8 @@ func doMigration(logger log.Logger, configstore cfgstore.Store) error {
} }
// Load the existing DB // Load the existing DB
diskfs, err := fs.NewDiskFilesystem(fs.DiskConfig{})
if err != nil {
logger.Error().WithError(err).Log("Accessing disk filesystem failed")
return fmt.Errorf("accessing disk filesystem failed: %w", err)
}
datastore, err := store.NewJSON(store.JSONConfig{ datastore, err := store.NewJSON(store.JSONConfig{
Filesystem: diskfs, Filesystem: fs,
Filepath: cfg.DB.Dir + "/db.json", Filepath: cfg.DB.Dir + "/db.json",
}) })
if err != nil { if err != nil {