mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +08:00
add more log for sync
This commit is contained in:
parent
38a7f63cc6
commit
d1836d3df8
@ -34,13 +34,13 @@ func CmdSync() cli.Command {
|
||||
Usage: "同步备份功能(Beta)",
|
||||
UsageText: cmder.App().Name + " sync",
|
||||
Description: `
|
||||
备份功能。指定本地目录和对应的一个网盘目录,以备份文件。
|
||||
备份功能。指定本地目录和对应的一个网盘目录,以备份文件。网盘目录必须和本地目录独占使用,不要用作其他他用途,不然备份可能会有问题。
|
||||
备份功能支持以下三种模式:
|
||||
1. upload
|
||||
备份本地文件,即上传本地文件到网盘,始终保持本地文件有一个完整的备份在网盘
|
||||
2. download
|
||||
备份云盘文件,即下载网盘文件到本地,始终保持网盘的文件有一个完整的备份在本地
|
||||
3. sync
|
||||
3. sync(慎用!!!双向备份过程会删除文件)
|
||||
双向备份,保持网盘文件和本地文件严格一致
|
||||
|
||||
请输入以下命令查看如何配置和启动:
|
||||
|
@ -51,8 +51,7 @@ func (f *FileActionTask) HashCode() string {
|
||||
}
|
||||
|
||||
func (f *FileActionTask) DoAction(ctx context.Context) error {
|
||||
logger.Verboseln("file action task")
|
||||
logger.Verboseln(f.syncItem)
|
||||
logger.Verboseln("file action task:", utils.ObjectToJsonStr(f.syncItem, false))
|
||||
if f.syncItem.Action == SyncFileActionUpload {
|
||||
if e := f.uploadFile(ctx); e != nil {
|
||||
// TODO: retry / cleanup downloading file
|
||||
|
@ -144,7 +144,7 @@ func (f *FileActionTaskManager) doLocalFileDiffRoutine(ctx context.Context) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
logger.Verboseln("do file diff process")
|
||||
//logger.Verboseln("do file diff process")
|
||||
localFiles := LocalFileList{}
|
||||
panFiles := PanFileList{}
|
||||
var err error
|
||||
@ -195,7 +195,7 @@ func (f *FileActionTaskManager) doPanFileDiffRoutine(ctx context.Context) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
logger.Verboseln("do file diff process")
|
||||
//logger.Verboseln("do file diff process")
|
||||
localFiles := LocalFileList{}
|
||||
panFiles := PanFileList{}
|
||||
var err error
|
||||
@ -445,7 +445,7 @@ func (f *FileActionTaskManager) doFileDiffRoutine(panFiles PanFileList, localFil
|
||||
|
||||
if strings.ToLower(panFile.Sha1Hash) == strings.ToLower(localFile.Sha1Hash) {
|
||||
// do nothing
|
||||
logger.Verboseln("no need to update file: ", localFile.Path)
|
||||
logger.Verboseln("file is the same, no need to update file: ", localFile.Path)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -647,7 +647,7 @@ func (f *FileActionTaskManager) fileActionTaskExecutor(ctx context.Context) {
|
||||
downloadWaitGroup.Wait()
|
||||
return
|
||||
default:
|
||||
logger.Verboseln("do file executor process")
|
||||
//logger.Verboseln("do file executor process")
|
||||
|
||||
// do upload
|
||||
uploadItem := f.getFromSyncDb(SyncFileActionUpload)
|
||||
|
@ -222,6 +222,7 @@ func (t *SyncTask) discardLocalFileDb(filePath string, startTimeUnix int64) {
|
||||
// label file discard
|
||||
file.ScanStatus = ScanStatusDiscard
|
||||
t.localFileDb.Update(file)
|
||||
logger.Verboseln("label local file discard: ", utils.ObjectToJsonStr(file, false))
|
||||
} else {
|
||||
if file.IsFolder() {
|
||||
t.discardLocalFileDb(file.Path, startTimeUnix)
|
||||
@ -323,6 +324,7 @@ func (t *SyncTask) scanLocalFile(ctx context.Context) {
|
||||
// append
|
||||
localFile.ScanTimeAt = utils.NowTimeStr()
|
||||
localFileAppendList = append(localFileAppendList, localFile)
|
||||
logger.Verboseln("add local file to db: ", utils.ObjectToJsonStr(localFile, false))
|
||||
} else {
|
||||
// update newest info into DB
|
||||
if localFile.UpdateTimeUnix() > localFileInDb.UpdateTimeUnix() {
|
||||
@ -334,6 +336,7 @@ func (t *SyncTask) scanLocalFile(ctx context.Context) {
|
||||
localFileInDb.FileType = localFile.FileType
|
||||
localFileInDb.ScanTimeAt = utils.NowTimeStr()
|
||||
localFileInDb.ScanStatus = ScanStatusNormal
|
||||
logger.Verboseln("update local file to db: ", utils.ObjectToJsonStr(localFileInDb, false))
|
||||
if _, er := t.localFileDb.Update(localFileInDb); er != nil {
|
||||
logger.Verboseln("local db update error ", er)
|
||||
}
|
||||
@ -370,6 +373,7 @@ func (t *SyncTask) discardPanFileDb(filePath string, startTimeUnix int64) {
|
||||
// label file discard
|
||||
file.ScanStatus = ScanStatusDiscard
|
||||
t.panFileDb.Update(file)
|
||||
logger.Verboseln("label pan file discard: ", utils.ObjectToJsonStr(file, false))
|
||||
} else {
|
||||
if file.IsFolder() {
|
||||
t.discardPanFileDb(file.Path, startTimeUnix)
|
||||
@ -455,6 +459,7 @@ func (t *SyncTask) scanPanFile(ctx context.Context) {
|
||||
pFile1 := NewPanFileItem(file)
|
||||
pFile1.ScanTimeAt = utils.NowTimeStr()
|
||||
panFileList = append(panFileList, pFile1)
|
||||
logger.Verboseln("add pan file to db: ", utils.ObjectToJsonStr(pFile1, false))
|
||||
} else {
|
||||
// update newest info into DB
|
||||
panFileInDb.DomainId = file.DomainId
|
||||
@ -468,6 +473,7 @@ func (t *SyncTask) scanPanFile(ctx context.Context) {
|
||||
panFileInDb.CreatedAt = file.CreatedAt
|
||||
panFileInDb.ScanTimeAt = utils.NowTimeStr()
|
||||
panFileInDb.ScanStatus = ScanStatusNormal
|
||||
logger.Verboseln("update pan file to db: ", utils.ObjectToJsonStr(panFileInDb, false))
|
||||
t.panFileDb.Update(panFileInDb)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user