mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-03 05:47:16 +08:00
fix no sync task error
This commit is contained in:
parent
232ab535ed
commit
1b2c8ae1ce
@ -172,11 +172,11 @@ func RunSync(fileDownloadParallel, fileUploadParallel int, downloadBlockSize, up
|
|||||||
if useInternalUrl {
|
if useInternalUrl {
|
||||||
typeUrlStr = "阿里ECS内部链接"
|
typeUrlStr = "阿里ECS内部链接"
|
||||||
}
|
}
|
||||||
fmt.Printf("链接类型:%s\n下载并发:%d\n上传并发:%d\n下载分片大小:%s\n上传分片大小:%s\n",
|
|
||||||
typeUrlStr, fileDownloadParallel, fileUploadParallel, converter.ConvertFileSize(downloadBlockSize, 2),
|
|
||||||
converter.ConvertFileSize(uploadBlockSize, 2))
|
|
||||||
syncMgr := syncdrive.NewSyncTaskManager(activeUser.DriveList.GetFileDriveId(), panClient, syncFolderRootPath,
|
syncMgr := syncdrive.NewSyncTaskManager(activeUser.DriveList.GetFileDriveId(), panClient, syncFolderRootPath,
|
||||||
fileDownloadParallel, fileUploadParallel, downloadBlockSize, uploadBlockSize, useInternalUrl)
|
fileDownloadParallel, fileUploadParallel, downloadBlockSize, uploadBlockSize, useInternalUrl)
|
||||||
|
fmt.Printf("备份配置文件:%s\n链接类型:%s\n下载并发:%d\n上传并发:%d\n下载分片大小:%s\n上传分片大小:%s\n",
|
||||||
|
syncMgr.ConfigFilePath(), typeUrlStr, fileDownloadParallel, fileUploadParallel, converter.ConvertFileSize(downloadBlockSize, 2),
|
||||||
|
converter.ConvertFileSize(uploadBlockSize, 2))
|
||||||
if _, e := syncMgr.Start(); e != nil {
|
if _, e := syncMgr.Start(); e != nil {
|
||||||
fmt.Println("启动任务失败:", e)
|
fmt.Println("启动任务失败:", e)
|
||||||
return
|
return
|
||||||
|
@ -70,7 +70,7 @@ func (m *SyncTaskManager) parseConfigFile() error {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
configFilePath := m.configFilePath()
|
configFilePath := m.ConfigFilePath()
|
||||||
r := &SyncDriveConfig{
|
r := &SyncDriveConfig{
|
||||||
ConfigVer: "1.0",
|
ConfigVer: "1.0",
|
||||||
SyncTaskList: []*SyncTask{},
|
SyncTaskList: []*SyncTask{},
|
||||||
@ -79,8 +79,8 @@ func (m *SyncTaskManager) parseConfigFile() error {
|
|||||||
|
|
||||||
if b, _ := utils.PathExists(configFilePath); b != true {
|
if b, _ := utils.PathExists(configFilePath); b != true {
|
||||||
//text := utils.ObjectToJsonStr(r, true)
|
//text := utils.ObjectToJsonStr(r, true)
|
||||||
//ioutil.WriteFile(configFilePath, []byte(text), 0600)
|
//ioutil.WriteFile(ConfigFilePath, []byte(text), 0600)
|
||||||
return fmt.Errorf("备份配置文件不存在")
|
return fmt.Errorf("备份配置文件不存在:" + m.ConfigFilePath())
|
||||||
}
|
}
|
||||||
data, e := ioutil.ReadFile(configFilePath)
|
data, e := ioutil.ReadFile(configFilePath)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
@ -96,14 +96,14 @@ func (m *SyncTaskManager) parseConfigFile() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SyncTaskManager) configFilePath() string {
|
func (m *SyncTaskManager) ConfigFilePath() string {
|
||||||
return path.Join(m.SyncConfigFolderPath, "sync_drive_config.json")
|
return path.Join(m.SyncConfigFolderPath, "sync_drive_config.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start 启动同步进程
|
// Start 启动同步进程
|
||||||
func (m *SyncTaskManager) Start() (bool, error) {
|
func (m *SyncTaskManager) Start() (bool, error) {
|
||||||
if m.parseConfigFile() != nil {
|
if er := m.parseConfigFile(); er != nil {
|
||||||
return false, nil
|
return false, er
|
||||||
}
|
}
|
||||||
if m.syncDriveConfig.SyncTaskList == nil || len(m.syncDriveConfig.SyncTaskList) == 0 {
|
if m.syncDriveConfig.SyncTaskList == nil || len(m.syncDriveConfig.SyncTaskList) == 0 {
|
||||||
return false, ErrSyncTaskListEmpty
|
return false, ErrSyncTaskListEmpty
|
||||||
@ -132,7 +132,7 @@ func (m *SyncTaskManager) Start() (bool, error) {
|
|||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
}
|
}
|
||||||
// save config file
|
// save config file
|
||||||
ioutil.WriteFile(m.configFilePath(), []byte(utils.ObjectToJsonStr(m.syncDriveConfig, true)), 0600)
|
ioutil.WriteFile(m.ConfigFilePath(), []byte(utils.ObjectToJsonStr(m.syncDriveConfig, true)), 0600)
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +149,6 @@ func (m *SyncTaskManager) Stop() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save config file
|
// save config file
|
||||||
ioutil.WriteFile(m.configFilePath(), []byte(utils.ObjectToJsonStr(m.syncDriveConfig, true)), 0600)
|
ioutil.WriteFile(m.ConfigFilePath(), []byte(utils.ObjectToJsonStr(m.syncDriveConfig, true)), 0600)
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user