Skip to content

Commit

Permalink
refactor with mount check for removal
Browse files Browse the repository at this point in the history
  • Loading branch information
sapk committed Jan 17, 2019
1 parent b58085f commit 157e7f6
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions rclone/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,21 @@ func (d *RcloneDriver) Remove(r *volume.RemoveRequest) error {
//if v.Connections == 0 {
// if m.Connections == 0 {
//Unmount
if err := d.runCmd(fmt.Sprintf("umount \"%s\"", m.Path)); err != nil {
mounted, err := m.isMounted()
if err != nil {
return err
}
//Remove mount point
if err := os.Remove(m.Path); err != nil {
return err
if mounted { //Only if mounted
if err := d.runCmd(fmt.Sprintf("umount \"%s\"", m.Path)); err != nil {
return err
}
}

if _, err := os.Stat(m.Path); !os.IsNotExist(err) {
//Remove mount point
if err := os.Remove(m.Path); err != nil {
return err
}
}
delete(d.mounts, v.Mount)
//}
Expand Down Expand Up @@ -339,7 +348,7 @@ func (d *RcloneDriver) Unmount(r *volume.UnmountRequest) error {
v.Connections = 0
} else {
if m.Connections <= 1 {
cmd := fmt.Sprintf("/usr/bin/umount %s", m.Path)
cmd := fmt.Sprintf("umount %s", m.Path)
if err := d.runCmd(cmd); err != nil {
return err
}
Expand Down

0 comments on commit 157e7f6

Please sign in to comment.