aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_remote_unmount.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-09-04 05:09:38 -0700
committerChris Lu <chris.lu@gmail.com>2021-09-04 05:09:38 -0700
commitc3db389e4249f2ab923b6d27fb61d69acc358e1b (patch)
treebbade90c0a861b716d3e4afa8fe26150fab99387 /weed/shell/command_remote_unmount.go
parente9ce0994537b58a3cc0f88098d9352c18b01ec96 (diff)
downloadseaweedfs-c3db389e4249f2ab923b6d27fb61d69acc358e1b.tar.xz
seaweedfs-c3db389e4249f2ab923b6d27fb61d69acc358e1b.zip
refactor
Diffstat (limited to 'weed/shell/command_remote_unmount.go')
-rw-r--r--weed/shell/command_remote_unmount.go32
1 files changed, 1 insertions, 31 deletions
diff --git a/weed/shell/command_remote_unmount.go b/weed/shell/command_remote_unmount.go
index ed5887a4a..04fd5e388 100644
--- a/weed/shell/command_remote_unmount.go
+++ b/weed/shell/command_remote_unmount.go
@@ -62,7 +62,7 @@ func (c *commandRemoteUnmount) Do(args []string, commandEnv *CommandEnv, writer
// store a mount configuration in filer
fmt.Fprintf(writer, "deleting mount for %s ...\n", *dir)
- if err = c.deleteMountMapping(commandEnv, *dir); err != nil {
+ if err = filer.DeleteMountMapping(commandEnv, *dir); err != nil {
return fmt.Errorf("delete mount mapping: %v", err)
}
@@ -119,33 +119,3 @@ func (c *commandRemoteUnmount) purgeMountedData(commandEnv *CommandEnv, dir stri
return nil
}
-func (c *commandRemoteUnmount) deleteMountMapping(commandEnv *CommandEnv, dir string) (err error) {
-
- // read current mapping
- var oldContent, newContent []byte
- err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
- oldContent, err = filer.ReadInsideFiler(client, filer.DirectoryEtcRemote, filer.REMOTE_STORAGE_MOUNT_FILE)
- return err
- })
- if err != nil {
- if err != filer_pb.ErrNotFound {
- return fmt.Errorf("read existing mapping: %v", err)
- }
- }
-
- // add new mapping
- newContent, err = filer.RemoveRemoteStorageMapping(oldContent, dir)
- if err != nil {
- return fmt.Errorf("delete mount %s: %v", dir, err)
- }
-
- // save back
- err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
- return filer.SaveInsideFiler(client, filer.DirectoryEtcRemote, filer.REMOTE_STORAGE_MOUNT_FILE, newContent)
- })
- if err != nil {
- return fmt.Errorf("save mapping: %v", err)
- }
-
- return nil
-}