mirror of
https://github.com/restic/restic.git
synced 2025-12-03 21:51:47 +00:00
backend: remove Test method
The Test method was only used in exactly one place, namely when trying to create a new repository it was used to check whether a config file already exists. Use a combination of Stat() and IsNotExist() instead.
This commit is contained in:
@@ -738,11 +738,11 @@ func (r *Repository) Init(ctx context.Context, version uint, password string, ch
|
||||
return fmt.Errorf("repository version %v too low", version)
|
||||
}
|
||||
|
||||
has, err := r.be.Test(ctx, restic.Handle{Type: restic.ConfigFile})
|
||||
if err != nil {
|
||||
_, err := r.be.Stat(ctx, restic.Handle{Type: restic.ConfigFile})
|
||||
if err != nil && !r.be.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
if has {
|
||||
if err == nil {
|
||||
return errors.New("repository master key and config already initialized")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user