aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_remote_uncache.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/shell/command_remote_uncache.go')
-rw-r--r--weed/shell/command_remote_uncache.go35
1 files changed, 19 insertions, 16 deletions
diff --git a/weed/shell/command_remote_uncache.go b/weed/shell/command_remote_uncache.go
index 77f3a2575..0d4e0cf7d 100644
--- a/weed/shell/command_remote_uncache.go
+++ b/weed/shell/command_remote_uncache.go
@@ -54,27 +54,30 @@ func (c *commandRemoteUncache) Do(args []string, commandEnv *CommandEnv, writer
if listErr != nil {
return listErr
}
- if *dir == "" {
- jsonPrintln(writer, mappings)
- fmt.Fprintln(writer, "need to specify '-dir' option")
- return nil
- }
+ if *dir != "" {
+ var localMountedDir string
+ for k := range mappings.Mappings {
+ if strings.HasPrefix(*dir, k) {
+ localMountedDir = k
+ }
+ }
+ if localMountedDir == "" {
+ jsonPrintln(writer, mappings)
+ fmt.Fprintf(writer, "%s is not mounted\n", *dir)
+ return nil
+ }
- var localMountedDir string
- for k := range mappings.Mappings {
- if strings.HasPrefix(*dir, k) {
- localMountedDir = k
+ // pull content from remote
+ if err = c.uncacheContentData(commandEnv, writer, util.FullPath(*dir), fileFiler); err != nil {
+ return fmt.Errorf("uncache content data: %v", err)
}
- }
- if localMountedDir == "" {
- jsonPrintln(writer, mappings)
- fmt.Fprintf(writer, "%s is not mounted\n", *dir)
return nil
}
- // pull content from remote
- if err = c.uncacheContentData(commandEnv, writer, util.FullPath(*dir), fileFiler); err != nil {
- return fmt.Errorf("uncache content data: %v", err)
+ for key, _ := range mappings.Mappings {
+ if err := c.uncacheContentData(commandEnv, writer, util.FullPath(key), fileFiler); err != nil {
+ return err
+ }
}
return nil