mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +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 {
|
||||
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,
|
||||
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 {
|
||||
fmt.Println("启动任务失败:", e)
|
||||
return
|
||||
|
@ -70,7 +70,7 @@ func (m *SyncTaskManager) parseConfigFile() error {
|
||||
]
|
||||
}
|
||||
*/
|
||||
configFilePath := m.configFilePath()
|
||||
configFilePath := m.ConfigFilePath()
|
||||
r := &SyncDriveConfig{
|
||||
ConfigVer: "1.0",
|
||||
SyncTaskList: []*SyncTask{},
|
||||
@ -79,8 +79,8 @@ func (m *SyncTaskManager) parseConfigFile() error {
|
||||
|
||||
if b, _ := utils.PathExists(configFilePath); b != true {
|
||||
//text := utils.ObjectToJsonStr(r, true)
|
||||
//ioutil.WriteFile(configFilePath, []byte(text), 0600)
|
||||
return fmt.Errorf("备份配置文件不存在")
|
||||
//ioutil.WriteFile(ConfigFilePath, []byte(text), 0600)
|
||||
return fmt.Errorf("备份配置文件不存在:" + m.ConfigFilePath())
|
||||
}
|
||||
data, e := ioutil.ReadFile(configFilePath)
|
||||
if e != nil {
|
||||
@ -96,14 +96,14 @@ func (m *SyncTaskManager) parseConfigFile() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SyncTaskManager) configFilePath() string {
|
||||
func (m *SyncTaskManager) ConfigFilePath() string {
|
||||
return path.Join(m.SyncConfigFolderPath, "sync_drive_config.json")
|
||||
}
|
||||
|
||||
// Start 启动同步进程
|
||||
func (m *SyncTaskManager) Start() (bool, error) {
|
||||
if m.parseConfigFile() != nil {
|
||||
return false, nil
|
||||
if er := m.parseConfigFile(); er != nil {
|
||||
return false, er
|
||||
}
|
||||
if m.syncDriveConfig.SyncTaskList == nil || len(m.syncDriveConfig.SyncTaskList) == 0 {
|
||||
return false, ErrSyncTaskListEmpty
|
||||
@ -132,7 +132,7 @@ func (m *SyncTaskManager) Start() (bool, error) {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
||||
@ -149,6 +149,6 @@ func (m *SyncTaskManager) Stop() (bool, error) {
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user