mirror of
https://github.com/restic/restic.git
synced 2024-12-25 09:18:55 +00:00
repository: unify repository version-specific initialization
Mark the master index as compressed also when initializing a new repository. This is only relevant for testing.
This commit is contained in:
parent
8776031f96
commit
abe5935693
1 changed files with 12 additions and 5 deletions
|
@ -116,6 +116,14 @@ func (r *Repository) DisableAutoIndexUpdate() {
|
||||||
r.noAutoIndexUpdate = true
|
r.noAutoIndexUpdate = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setConfig assigns the given config and updates the repository parameters accordingly
|
||||||
|
func (r *Repository) setConfig(cfg restic.Config) {
|
||||||
|
r.cfg = cfg
|
||||||
|
if r.cfg.Version >= 2 {
|
||||||
|
r.idx.markCompressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Config returns the repository configuration.
|
// Config returns the repository configuration.
|
||||||
func (r *Repository) Config() restic.Config {
|
func (r *Repository) Config() restic.Config {
|
||||||
return r.cfg
|
return r.cfg
|
||||||
|
@ -772,15 +780,14 @@ func (r *Repository) SearchKey(ctx context.Context, password string, maxKeys int
|
||||||
r.dataPM.key = key.master
|
r.dataPM.key = key.master
|
||||||
r.treePM.key = key.master
|
r.treePM.key = key.master
|
||||||
r.keyName = key.Name()
|
r.keyName = key.Name()
|
||||||
r.cfg, err = restic.LoadConfig(ctx, r)
|
cfg, err := restic.LoadConfig(ctx, r)
|
||||||
if err == crypto.ErrUnauthenticated {
|
if err == crypto.ErrUnauthenticated {
|
||||||
return errors.Fatalf("config or key %v is damaged: %v", key.Name(), err)
|
return errors.Fatalf("config or key %v is damaged: %v", key.Name(), err)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return errors.Fatalf("config cannot be loaded: %v", err)
|
return errors.Fatalf("config cannot be loaded: %v", err)
|
||||||
}
|
}
|
||||||
if r.Config().Version >= 2 {
|
|
||||||
r.idx.markCompressed()
|
r.setConfig(cfg)
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,7 +833,7 @@ func (r *Repository) init(ctx context.Context, password string, cfg restic.Confi
|
||||||
r.dataPM.key = key.master
|
r.dataPM.key = key.master
|
||||||
r.treePM.key = key.master
|
r.treePM.key = key.master
|
||||||
r.keyName = key.Name()
|
r.keyName = key.Name()
|
||||||
r.cfg = cfg
|
r.setConfig(cfg)
|
||||||
_, err = r.SaveJSONUnpacked(ctx, restic.ConfigFile, cfg)
|
_, err = r.SaveJSONUnpacked(ctx, restic.ConfigFile, cfg)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue