Skip to content

Commit

Permalink
Merge pull request #233 from Szubie/mount-ensure-removed
Browse files Browse the repository at this point in the history
Allow for deletion of units with active mounts
  • Loading branch information
idroz committed Dec 15, 2022
2 parents 281cc22 + e73460c commit 4e9c7fd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions platform/host_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,12 @@ func (bh *BraveHost) DeleteUnit(name string) error {
return err
}

for _, d := range inst.Devices {
if (d["type"] == "disk") && (d["path"] != "/") {
log.Fatal("unable to remove a unit with a mounted directory")
for deviceName, d := range inst.Devices {
if (d["type"] == "disk") && strings.HasPrefix(deviceName, "brave_") {
err = bh.UmountShare(name, d["path"])
if err != nil {
log.Printf("failed to unmount %q from multipass host: %s\n", path.Join("/home/ubuntu/volumes/", deviceName), err)
}
}
}

Expand Down

0 comments on commit 4e9c7fd

Please sign in to comment.