mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +08:00
fix that the folder will created repeatly while uploading file
This commit is contained in:
parent
c9c33217d2
commit
5b22c4400a
@ -451,6 +451,7 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) {
|
|||||||
// 这样空文件夹也可以正确上传
|
// 这样空文件夹也可以正确上传
|
||||||
saveFilePath := subSavePath
|
saveFilePath := subSavePath
|
||||||
if saveFilePath != "/" {
|
if saveFilePath != "/" {
|
||||||
|
folderCreateMutex.Lock()
|
||||||
fmt.Printf("正在检测和创建云盘文件夹: %s\n", saveFilePath)
|
fmt.Printf("正在检测和创建云盘文件夹: %s\n", saveFilePath)
|
||||||
_, apierr1 := activeUser.PanClient().FileInfoByPath(opt.DriveId, saveFilePath)
|
_, apierr1 := activeUser.PanClient().FileInfoByPath(opt.DriveId, saveFilePath)
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
@ -461,6 +462,7 @@ func RunUpload(localPaths []string, savePath string, opt *UploadOptions) {
|
|||||||
fmt.Printf("创建云盘文件夹失败: %s\n", saveFilePath)
|
fmt.Printf("创建云盘文件夹失败: %s\n", saveFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
folderCreateMutex.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -350,6 +350,7 @@ StepUploadPrepareUpload:
|
|||||||
// 创建云盘文件夹
|
// 创建云盘文件夹
|
||||||
saveFilePath = path.Dir(utu.SavePath)
|
saveFilePath = path.Dir(utu.SavePath)
|
||||||
if saveFilePath != "/" {
|
if saveFilePath != "/" {
|
||||||
|
utu.FolderCreateMutex.Lock()
|
||||||
fmt.Printf("[%s] %s 正在检测和创建云盘文件夹: %s\n", utu.taskInfo.Id(), time.Now().Format("2006-01-02 15:04:06"), saveFilePath)
|
fmt.Printf("[%s] %s 正在检测和创建云盘文件夹: %s\n", utu.taskInfo.Id(), time.Now().Format("2006-01-02 15:04:06"), saveFilePath)
|
||||||
fe, apierr1 := utu.PanClient.FileInfoByPath(utu.DriveId, saveFilePath)
|
fe, apierr1 := utu.PanClient.FileInfoByPath(utu.DriveId, saveFilePath)
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
@ -361,6 +362,7 @@ StepUploadPrepareUpload:
|
|||||||
if apierr != nil || rs.FileId == "" {
|
if apierr != nil || rs.FileId == "" {
|
||||||
result.Err = apierr
|
result.Err = apierr
|
||||||
result.ResultMessage = "创建云盘文件夹失败"
|
result.ResultMessage = "创建云盘文件夹失败"
|
||||||
|
utu.FolderCreateMutex.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.Verbosef("[%s] %s 创建云盘文件夹成功\n", utu.taskInfo.Id(), time.Now().Format("2006-01-02 15:04:06"))
|
logger.Verbosef("[%s] %s 创建云盘文件夹成功\n", utu.taskInfo.Id(), time.Now().Format("2006-01-02 15:04:06"))
|
||||||
@ -368,6 +370,7 @@ StepUploadPrepareUpload:
|
|||||||
rs = &aliyunpan.MkdirResult{}
|
rs = &aliyunpan.MkdirResult{}
|
||||||
rs.FileId = fe.FileId
|
rs.FileId = fe.FileId
|
||||||
}
|
}
|
||||||
|
utu.FolderCreateMutex.Unlock()
|
||||||
} else {
|
} else {
|
||||||
rs = &aliyunpan.MkdirResult{}
|
rs = &aliyunpan.MkdirResult{}
|
||||||
rs.FileId = ""
|
rs.FileId = ""
|
||||||
|
Loading…
Reference in New Issue
Block a user