Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fs.mergeVolumes: change dir to a named parameter

Amir H. Yeganemehr6f559fe8386d
diff --git a/weed/shell/command_fs_merge_volumes.go b/weed/shell/command_fs_merge_volumes.go
index b972c1adfa..4a6048a437 100644
--- a/weed/shell/command_fs_merge_volumes.go
+++ b/weed/shell/command_fs_merge_volumes.go
@@ -44,20 +44,14 @@ func (c *commandFsMergeVolumes) Help() string {
This would help clear half-full volumes and let vacuum system to delete them later.
- fs.mergeVolumes [-toVolumeId=y] [-fromVolumeId=x] [-collection="*"] [-apply] [/dir/]
+ fs.mergeVolumes [-toVolumeId=y] [-fromVolumeId=x] [-collection="*"] [-dir=/] [-apply]
`
}
func (c *commandFsMergeVolumes) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
- dir, err := commandEnv.parseUrl(findInputDirectory(args))
- if err != nil {
- return err
- }
- if dir != "/" {
- dir = strings.TrimRight(dir, "/")
- }
fsMergeVolumesCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
+ dirArg := fsMergeVolumesCommand.String("dir", "/", "base directory to find and update files")
fromVolumeArg := fsMergeVolumesCommand.Uint("fromVolumeId", 0, "move chunks with this volume id")
toVolumeArg := fsMergeVolumesCommand.Uint("toVolumeId", 0, "change chunks to this volume id")
collectionArg := fsMergeVolumesCommand.String("collection", "*", "Name of collection to merge")
@@ -65,6 +59,12 @@ func (c *commandFsMergeVolumes) Do(args []string, commandEnv *CommandEnv, writer
if err = fsMergeVolumesCommand.Parse(args); err != nil {
return err
}
+
+ dir := *dirArg
+ if dir != "/" {
+ dir = strings.TrimRight(dir, "/")
+ }
+
fromVolumeId := needle.VolumeId(*fromVolumeArg)
toVolumeId := needle.VolumeId(*toVolumeArg)