mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +08:00
fix file name auto complete issue
This commit is contained in:
parent
53bdf34691
commit
bf26202290
@ -68,6 +68,9 @@ func RunMkdir(driveId, name string) {
|
|||||||
|
|
||||||
if rs.FileId != "" {
|
if rs.FileId != "" {
|
||||||
fmt.Println("创建文件夹成功: ", fullpath)
|
fmt.Println("创建文件夹成功: ", fullpath)
|
||||||
|
|
||||||
|
// cache
|
||||||
|
activeUser.DeleteCache(GetAllPathFolderByPath(fullpath))
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("创建文件夹失败: ", fullpath)
|
fmt.Println("创建文件夹失败: ", fullpath)
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ func CmdMv() cli.Command {
|
|||||||
// RunMove 执行移动文件/目录
|
// RunMove 执行移动文件/目录
|
||||||
func RunMove(driveId string, paths ...string) {
|
func RunMove(driveId string, paths ...string) {
|
||||||
activeUser := GetActiveUser()
|
activeUser := GetActiveUser()
|
||||||
|
cacheCleanPaths := []string{}
|
||||||
opFileList, targetFile, _, err := getFileInfo(driveId, paths...)
|
opFileList, targetFile, _, err := getFileInfo(driveId, paths...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@ -77,6 +78,7 @@ func RunMove(driveId string, paths ...string) {
|
|||||||
fmt.Println("没有有效的文件可移动")
|
fmt.Println("没有有效的文件可移动")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
cacheCleanPaths = append(cacheCleanPaths, targetFile.Path)
|
||||||
|
|
||||||
failedMoveFiles := []*aliyunpan.FileEntity{}
|
failedMoveFiles := []*aliyunpan.FileEntity{}
|
||||||
moveFileParamList := []*aliyunpan.FileMoveParam{}
|
moveFileParamList := []*aliyunpan.FileMoveParam{}
|
||||||
@ -90,6 +92,7 @@ func RunMove(driveId string, paths ...string) {
|
|||||||
ToDriveId: driveId,
|
ToDriveId: driveId,
|
||||||
ToParentFileId: targetFile.FileId,
|
ToParentFileId: targetFile.FileId,
|
||||||
})
|
})
|
||||||
|
cacheCleanPaths = append(cacheCleanPaths, path.Dir(mfi.Path))
|
||||||
}
|
}
|
||||||
fmr,er := activeUser.PanClient().FileMove(moveFileParamList)
|
fmr,er := activeUser.PanClient().FileMove(moveFileParamList)
|
||||||
|
|
||||||
@ -108,6 +111,7 @@ func RunMove(driveId string, paths ...string) {
|
|||||||
}
|
}
|
||||||
if er == nil {
|
if er == nil {
|
||||||
fmt.Println("操作成功, 已移动文件到目标目录: ", targetFile.Path)
|
fmt.Println("操作成功, 已移动文件到目标目录: ", targetFile.Path)
|
||||||
|
activeUser.DeleteCache(cacheCleanPaths)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("无法移动文件,请稍后重试")
|
fmt.Println("无法移动文件,请稍后重试")
|
||||||
}
|
}
|
||||||
|
@ -102,4 +102,5 @@ func RunRename(driveId string, oldName string, newName string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("重命名文件成功:%s -> %s\n", path.Base(oldName), path.Base(newName))
|
fmt.Printf("重命名文件成功:%s -> %s\n", path.Base(oldName), path.Base(newName))
|
||||||
|
activeUser.DeleteOneCache(path.Dir(newName))
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@ func CmdRm() cli.Command {
|
|||||||
func RunRemove(driveId string, paths ...string) {
|
func RunRemove(driveId string, paths ...string) {
|
||||||
activeUser := GetActiveUser()
|
activeUser := GetActiveUser()
|
||||||
|
|
||||||
|
cacheCleanDirs := []string{}
|
||||||
failedRmPaths := make([]string, 0, len(paths))
|
failedRmPaths := make([]string, 0, len(paths))
|
||||||
delFileInfos := []*aliyunpan.FileBatchActionParam{}
|
delFileInfos := []*aliyunpan.FileBatchActionParam{}
|
||||||
fileId2FileEntity := map[string]*aliyunpan.FileEntity{}
|
fileId2FileEntity := map[string]*aliyunpan.FileEntity{}
|
||||||
@ -90,6 +91,7 @@ func RunRemove(driveId string, paths ...string) {
|
|||||||
FileId:fe.FileId,
|
FileId:fe.FileId,
|
||||||
})
|
})
|
||||||
fileId2FileEntity[fe.FileId] = fe
|
fileId2FileEntity[fe.FileId] = fe
|
||||||
|
cacheCleanDirs = append(cacheCleanDirs, path.Dir(fe.Path))
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
@ -116,6 +118,7 @@ func RunRemove(driveId string, paths ...string) {
|
|||||||
if len(successDelFileEntity) > 0 {
|
if len(successDelFileEntity) > 0 {
|
||||||
fmt.Println("操作成功, 以下文件/目录已删除, 可在云盘文件回收站找回: ")
|
fmt.Println("操作成功, 以下文件/目录已删除, 可在云盘文件回收站找回: ")
|
||||||
pnt()
|
pnt()
|
||||||
|
activeUser.DeleteCache(cacheCleanDirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(successDelFileEntity) == 0 && err != nil {
|
if len(successDelFileEntity) == 0 && err != nil {
|
||||||
|
@ -442,7 +442,7 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) {
|
|||||||
tb.Render()
|
tb.Render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
activeUser.DeleteCache(GetAllPathFolderByPath(savePath))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 是否是排除上传的文件
|
// 是否是排除上传的文件
|
||||||
|
@ -92,4 +92,16 @@ func RandomStr(count int) string {
|
|||||||
str.WriteByte(byte(STR_SET[rand.Intn(len(STR_SET))]))
|
str.WriteByte(byte(STR_SET[rand.Intn(len(STR_SET))]))
|
||||||
}
|
}
|
||||||
return str.String()
|
return str.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetAllPathFolderByPath(pathStr string) []string {
|
||||||
|
dirNames := strings.Split(pathStr, "/")
|
||||||
|
dirs := []string{}
|
||||||
|
p := "/"
|
||||||
|
dirs = append(dirs, p)
|
||||||
|
for _,s := range dirNames {
|
||||||
|
p = path.Join(p, s)
|
||||||
|
dirs = append(dirs, p)
|
||||||
|
}
|
||||||
|
return dirs
|
||||||
}
|
}
|
@ -8,8 +8,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// deleteCache 删除含有 dirs 的缓存
|
// DeleteCache 删除含有 dirs 的缓存
|
||||||
func (pu *PanUser) deleteCache(dirs []string) {
|
func (pu *PanUser) DeleteCache(dirs []string) {
|
||||||
cache := pu.cacheOpMap.LazyInitCachePoolOp(pu.ActiveDriveId)
|
cache := pu.cacheOpMap.LazyInitCachePoolOp(pu.ActiveDriveId)
|
||||||
for _, v := range dirs {
|
for _, v := range dirs {
|
||||||
key := v + "_" + "OrderByName"
|
key := v + "_" + "OrderByName"
|
||||||
@ -20,6 +20,12 @@ func (pu *PanUser) deleteCache(dirs []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteOneCache 删除缓存
|
||||||
|
func (pu *PanUser) DeleteOneCache(dirPath string) {
|
||||||
|
ps := []string{dirPath}
|
||||||
|
pu.DeleteCache(ps)
|
||||||
|
}
|
||||||
|
|
||||||
// CacheFilesDirectoriesList 缓存获取
|
// CacheFilesDirectoriesList 缓存获取
|
||||||
func (pu *PanUser) CacheFilesDirectoriesList(pathStr string) (fdl aliyunpan.FileList, apiError *apierror.ApiError) {
|
func (pu *PanUser) CacheFilesDirectoriesList(pathStr string) (fdl aliyunpan.FileList, apiError *apierror.ApiError) {
|
||||||
data := pu.cacheOpMap.CacheOperation(pu.ActiveDriveId, pathStr+"_OrderByName", func() expires.DataExpires {
|
data := pu.cacheOpMap.CacheOperation(pu.ActiveDriveId, pathStr+"_OrderByName", func() expires.DataExpires {
|
||||||
|
Loading…
Reference in New Issue
Block a user