Skip to content

Commit

Permalink
Allow removing uninitialized mounts
Browse files Browse the repository at this point in the history
Previously we were overly finicky when removing mounts.
If a mount isn't mounted or initialized we shouldn't care.
If it's in the config remove it, if not don't.

Fixes #1746

RELEASE_NOTES=[BUGFIX] Always allow removing mounts

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz committed Jan 22, 2021
1 parent 61329b3 commit 97171c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/store/root/mount.go
Expand Up @@ -86,10 +86,10 @@ func (r *Store) initSub(ctx context.Context, alias, path string, keys []string)
// RemoveMount removes and existing mount
func (r *Store) RemoveMount(ctx context.Context, alias string) error {
if _, found := r.mounts[alias]; !found {
return errors.Errorf("%s is not mounted", alias)
out.Warning(ctx, "%s is not mounted", alias)
}
if _, found := r.mounts[alias]; !found {
out.Print(ctx, "%s is not initialized", alias)
out.Warning(ctx, "%s is not initialized", alias)
}
delete(r.mounts, alias)
delete(r.cfg.Mounts, alias)
Expand Down
3 changes: 2 additions & 1 deletion internal/store/root/mount_test.go
Expand Up @@ -33,5 +33,6 @@ func TestMount(t *testing.T) {
assert.Error(t, err)
assert.Nil(t, sub)

assert.Error(t, rs.RemoveMount(ctx, "foo"))
// removing mounts should never fail
assert.NoError(t, rs.RemoveMount(ctx, "foo"))
}

0 comments on commit 97171c0

Please sign in to comment.