Skip to content

Commit 6990543

Browse files
committed
feat: update transfer command to remove target path requirement and adjust usage instructions
1 parent dd0dea8 commit 6990543

File tree

5 files changed

+12
-20
lines changed

5 files changed

+12
-20
lines changed

client/bot/handlers/transfer.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package handlers
22

33
import (
44
"fmt"
5-
"path"
65
"regexp"
76
"strings"
87

@@ -28,7 +27,7 @@ func handleTransferCmd(ctx *ext.Context, update *ext.Update) error {
2827
logger := log.FromContext(ctx)
2928
args := strutil.ParseArgsRespectQuotes(update.EffectiveMessage.Text)
3029

31-
if len(args) < 3 {
30+
if len(args) < 2 {
3231
ctx.Reply(update, ext.ReplyTextString(i18n.T(i18nk.BotMsgTransferUsage, nil)), nil)
3332
return dispatcher.EndGroups
3433
}
@@ -42,9 +41,6 @@ func handleTransferCmd(ctx *ext.Context, update *ext.Update) error {
4241
sourceStorageName := sourceParts[0]
4342
sourcePath := sourceParts[1]
4443

45-
// Parse target path (without storage name)
46-
targetPath := args[2]
47-
4844
userID := update.GetUserChat().GetID()
4945

5046
// Get source storage
@@ -94,8 +90,8 @@ func handleTransferCmd(ctx *ext.Context, update *ext.Update) error {
9490

9591
// Optional filter
9692
var filter *regexp.Regexp
97-
if len(args) >= 4 {
98-
filter, err = regexp.Compile(args[3])
93+
if len(args) >= 3 {
94+
filter, err = regexp.Compile(args[2])
9995
if err != nil {
10096
ctx.EditMessage(update.EffectiveChat().GetID(), &tg.MessagesEditMessageRequest{
10197
ID: replied.ID,
@@ -139,7 +135,6 @@ func handleTransferCmd(ctx *ext.Context, update *ext.Update) error {
139135
TransferSourceStorName: sourceStorageName,
140136
TransferSourcePath: sourcePath,
141137
TransferFiles: filePaths,
142-
TransferTargetPath: targetPath,
143138
})
144139
if err != nil {
145140
logger.Errorf("Failed to build storage selection keyboard: %s", err)
@@ -209,7 +204,6 @@ func handleTransferCallback(ctx *ext.Context, userID int64, targetStorage storag
209204
}
210205

211206
// Build task elements for the selected files
212-
targetPath := path.Join(dirPath, data.TransferTargetPath)
213207
elems := make([]transfer.TaskElement, 0, len(data.TransferFiles))
214208
var totalSize int64
215209
for _, filePath := range data.TransferFiles {
@@ -218,7 +212,7 @@ func handleTransferCallback(ctx *ext.Context, userID int64, targetStorage storag
218212
logger.Warnf("File not found in source storage: %s", filePath)
219213
continue
220214
}
221-
elem := transfer.NewTaskElement(sourceStorage, fileInfo, targetStorage, targetPath)
215+
elem := transfer.NewTaskElement(sourceStorage, fileInfo, targetStorage, dirPath)
222216
elems = append(elems, *elem)
223217
totalSize += fileInfo.Size
224218
}

client/bot/handlers/utils/msgelem/storage.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func BuildAddSelectStorageKeyboard(stors []storage.Storage, adddata tcbdata.Add)
5757
TransferSourceStorName: adddata.TransferSourceStorName,
5858
TransferSourcePath: adddata.TransferSourcePath,
5959
TransferFiles: adddata.TransferFiles,
60-
TransferTargetPath: adddata.TransferTargetPath,
6160
}
6261
dataid := xid.New().String()
6362
err := cache.Set(dataid, data)

common/i18n/locale/en.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ bot:
299299
error_download_failed: "yt-dlp download failed: {{.Error}}"
300300
transfer:
301301
usage: |
302-
Usage: /transfer <source_storage>:/<source_path> <target_path> [filter]
302+
Usage: /transfer <source_storage>:/<source_path> [filter]
303303
Examples:
304-
/transfer local1:/downloads /backup
305-
/transfer alist1:/media/photos /photos
306-
/transfer webdav1:/files /archive ".*\.mp4$"
304+
/transfer local1:/downloads
305+
/transfer alist1:/media/photos
306+
/transfer webdav1:/files ".*\.mp4$"
307307
error_invalid_source: "Invalid source path format, should be: storage_name:/path"
308308
error_invalid_target: "Invalid target path format, should be: storage_name:/path"
309309
error_storage_not_found: "Storage '{{.StorageName}}' not found or access denied: {{.Error}}"

common/i18n/locale/zh-Hans.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,11 @@ bot:
300300
error_download_failed: "yt-dlp 下载失败: {{.Error}}"
301301
transfer:
302302
usage: |
303-
用法: /transfer <source_storage>:/<source_path> <target_path> [filter]
303+
用法: /transfer <source_storage>:/<source_path> [filter]
304304
示例:
305-
/transfer local1:/downloads /backup
306-
/transfer alist1:/media/photos /photos
307-
/transfer webdav1:/files /archive ".*\.mp4$"
305+
/transfer local1:/downloads
306+
/transfer alist1:/media/photos
307+
/transfer webdav1:/files ".*\.mp4$"
308308
error_invalid_source: "源路径格式无效,应为: storage_name:/path"
309309
error_invalid_target: "目标路径格式无效,应为: storage_name:/path"
310310
error_storage_not_found: "存储端 '{{.StorageName}}' 不存在或您无权访问: {{.Error}}"

pkg/tcbdata/data.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ type Add struct {
5454
TransferSourceStorName string
5555
TransferSourcePath string
5656
TransferFiles []string // file paths relative to source storage
57-
TransferTargetPath string
5857
}
5958

6059
type SetDefaultStorage struct {

0 commit comments

Comments
 (0)