Skip to content

Commit

Permalink
🎨 Improve data sync
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Nov 11, 2023
1 parent 59dbd8b commit 3b36f11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
4 changes: 2 additions & 2 deletions ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (repo *Repo) Latest() (ret *entity.Index, err error) {
if nil != err {
return
}
logging.LogInfof("got latest [%s, %s]", ret.ID, time.UnixMilli(ret.Created).Format("2006-01-02 15:04:05"))
logging.LogInfof("got local latest [device=%s/%s, id=%s, created=%s]", ret.SystemID, ret.SystemOS, ret.ID, time.UnixMilli(ret.Created).Format("2006-01-02 15:04:05"))
return
}

Expand All @@ -60,7 +60,7 @@ func (repo *Repo) UpdateLatest(index *entity.Index) (err error) {
if nil != err {
return
}
logging.LogInfof("updated latest to [%s, %s]", index.ID, time.UnixMilli(index.Created).Format("2006-01-02 15:04:05"))
logging.LogInfof("updated local latest to [device=%s/%s, id=%s, created=%s]", index.SystemID, index.SystemOS, index.ID, time.UnixMilli(index.Created).Format("2006-01-02 15:04:05"))
return
}

Expand Down
15 changes: 4 additions & 11 deletions sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,6 @@ func (repo *Repo) sync0(context map[string]interface{},
return
}

// 更新本地 latest 引用
err = repo.UpdateLatest(latest)
if nil != err {
logging.LogErrorf("update latest failed: %s", err)
return
}

// 更新本地同步点
err = repo.UpdateLatestSync(latest)
if nil != err {
Expand Down Expand Up @@ -1039,7 +1032,7 @@ func (repo *Repo) uploadIndex(index *entity.Index, context map[string]interface{
eventbus.Publish(eventbus.EvtCloudBeforeUploadIndex, context, index.ID)
length, err := repo.cloud.UploadObject(path.Join("indexes", index.ID), false)
uploadBytes += length
logging.LogInfof("uploaded index [%s, %s]", index.ID, time.UnixMilli(index.Created).Format("2006-01-02 15:04:05"))
logging.LogInfof("uploaded index [device=%s/%s, id=%s, created=%s]", index.SystemID, index.SystemOS, index.ID, time.UnixMilli(index.Created).Format("2006-01-02 15:04:05"))
return
}

Expand Down Expand Up @@ -1247,7 +1240,7 @@ func (repo *Repo) UpdateLatestSync(index *entity.Index) (err error) {
if nil != err {
return
}
logging.LogInfof("updated latest sync [%s, %s]", index.ID, time.UnixMilli(index.Created).Format("2006-01-02 15:04:05"))
logging.LogInfof("updated latest sync [device=%s/%s, id=%s, created=%s]", index.SystemID, index.SystemOS, index.ID, time.UnixMilli(index.Created).Format("2006-01-02 15:04:05"))
return
}

Expand Down Expand Up @@ -1319,7 +1312,7 @@ func (repo *Repo) latestSync() (ret *entity.Index) {
logging.LogWarnf("get latest sync index failed: %s", err)
return
}
logging.LogInfof("got latest sync [%s, %s]", ret.ID, time.UnixMilli(ret.Created).Format("2006-01-02 15:04:05"))
logging.LogInfof("got latest sync [device=%s/%s, id=%s, created=%s]", ret.SystemID, ret.SystemOS, ret.ID, time.UnixMilli(ret.Created).Format("2006-01-02 15:04:05"))
return
}

Expand Down Expand Up @@ -1431,7 +1424,7 @@ func (repo *Repo) downloadCloudLatest(context map[string]interface{}) (downloadB
}
downloadBytes += int64(len(data))

logging.LogInfof("got cloud latest [%s, %s]", index.ID, time.UnixMilli(index.Created).Format("2006-01-02 15:04:05"))
logging.LogInfof("got cloud latest [device=%s/%s, id=%s, created=%s]", index.SystemID, index.SystemOS, index.ID, time.UnixMilli(index.Created).Format("2006-01-02 15:04:05"))
return
}

Expand Down
7 changes: 0 additions & 7 deletions sync_manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,6 @@ func (repo *Repo) SyncDownload(context map[string]interface{}) (mergeResult *Mer
return
}

// 更新本地 latest 引用
err = repo.UpdateLatest(latest)
if nil != err {
logging.LogErrorf("update latest failed: %s", err)
return
}

// 更新本地同步点
err = repo.UpdateLatestSync(latest)
if nil != err {
Expand Down

0 comments on commit 3b36f11

Please sign in to comment.