repo: Fix fsrepo.SetStorage on init

This commit is contained in:
Łukasz Magiera 2020-03-09 22:46:17 +01:00
parent fe85c4111a
commit 0c2af7a8ee

View File

@ -283,11 +283,11 @@ func (fsr *fsLockedRepo) GetStorage() (config.StorageConfig, error) {
fsr.storageLk.Lock() fsr.storageLk.Lock()
defer fsr.storageLk.Unlock() defer fsr.storageLk.Unlock()
return fsr.getStorage() return fsr.getStorage(nil)
} }
func (fsr *fsLockedRepo) getStorage() (config.StorageConfig, error) { func (fsr *fsLockedRepo) getStorage(def *config.StorageConfig) (config.StorageConfig, error) {
c, err := config.StorageFromFile(fsr.join(fsStorageConfig), nil) c, err := config.StorageFromFile(fsr.join(fsStorageConfig), def)
if err != nil { if err != nil {
return config.StorageConfig{}, err return config.StorageConfig{}, err
} }
@ -298,7 +298,7 @@ func (fsr *fsLockedRepo) SetStorage(c func(*config.StorageConfig)) error {
fsr.storageLk.Lock() fsr.storageLk.Lock()
defer fsr.storageLk.Unlock() defer fsr.storageLk.Unlock()
sc, err := fsr.getStorage() sc, err := fsr.getStorage(&config.StorageConfig{})
if err != nil { if err != nil {
return xerrors.Errorf("get storage: %w", err) return xerrors.Errorf("get storage: %w", err)
} }