mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
fix sync download bug
This commit is contained in:
parent
8955eeec92
commit
ab6290e7a3
@ -42,8 +42,8 @@ func (f *FileActionTask) HashCode() string {
|
||||
}
|
||||
|
||||
func (f *FileActionTask) DoAction(ctx context.Context) error {
|
||||
fmt.Println("\nfile action task")
|
||||
fmt.Println(f.syncItem)
|
||||
logger.Verboseln("file action task")
|
||||
logger.Verboseln(f.syncItem)
|
||||
if f.syncItem.Action == SyncFileActionUpload {
|
||||
if e := f.uploadFile(); e != nil {
|
||||
return e
|
||||
@ -93,12 +93,12 @@ func (f *FileActionTask) DoAction(ctx context.Context) error {
|
||||
|
||||
func (f *FileActionTask) downloadFile() error {
|
||||
// check local file existed or not
|
||||
//if b, e := utils.PathExists(f.syncItem.getLocalFileFullPath()); e == nil && b {
|
||||
// // file existed
|
||||
// logger.Verbosef("delete local old file")
|
||||
// os.Remove(f.syncItem.getLocalFileFullPath())
|
||||
// time.Sleep(200 * time.Millisecond)
|
||||
//}
|
||||
if b, e := utils.PathExists(f.syncItem.getLocalFileFullPath()); e == nil && b {
|
||||
// file existed
|
||||
logger.Verbosef("delete local old file")
|
||||
os.Remove(f.syncItem.getLocalFileFullPath())
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
|
||||
durl, apierr := f.panClient.GetFileDownloadUrl(&aliyunpan.GetFileDownloadUrlParam{
|
||||
DriveId: f.syncItem.PanFile.DriveId,
|
||||
|
@ -79,24 +79,7 @@ func (t *SyncTask) String() string {
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
func (t *SyncTask) setup() error {
|
||||
t.localFileDb = NewLocalSyncDb(t.localSyncDbFullPath())
|
||||
t.panFileDb = NewPanSyncDb(t.panSyncDbFullPath())
|
||||
t.syncFileDb = NewSyncFileDb(t.syncFileDbFullPath())
|
||||
if _, e := t.localFileDb.Open(); e != nil {
|
||||
return e
|
||||
}
|
||||
if _, e := t.panFileDb.Open(); e != nil {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start 启动同步任务
|
||||
func (t *SyncTask) Start() error {
|
||||
if t.ctx != nil {
|
||||
return fmt.Errorf("task have starting")
|
||||
}
|
||||
func (t *SyncTask) setupDb() error {
|
||||
t.localFileDb = NewLocalSyncDb(t.localSyncDbFullPath())
|
||||
t.panFileDb = NewPanSyncDb(t.panSyncDbFullPath())
|
||||
t.syncFileDb = NewSyncFileDb(t.syncFileDbFullPath())
|
||||
@ -109,6 +92,15 @@ func (t *SyncTask) Start() error {
|
||||
if _, e := t.syncFileDb.Open(); e != nil {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start 启动同步任务
|
||||
func (t *SyncTask) Start() error {
|
||||
if t.ctx != nil {
|
||||
return fmt.Errorf("task have starting")
|
||||
}
|
||||
t.setupDb()
|
||||
|
||||
if t.fileActionTaskManager == nil {
|
||||
t.fileActionTaskManager = NewFileActionTaskManager(t)
|
||||
@ -123,7 +115,10 @@ func (t *SyncTask) Start() error {
|
||||
go t.scanLocalFile(t.ctx)
|
||||
go t.scanPanFile(t.ctx)
|
||||
|
||||
//t.fileActionTaskManager.Start()
|
||||
// start file sync manager
|
||||
if e := t.fileActionTaskManager.Start(); e != nil {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user