Skip to content

Commit

Permalink
added updatedAt check while syncing file to remote
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorro30 committed Feb 4, 2024
1 parent 464260a commit 7ec29ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions zboxcore/sdk/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ func addLocalFileList(root string, fMap map[string]FileInfo, dirList *[]string,
if info.IsDir() {
*dirList = append(*dirList, lPath)
} else {
fMap[lPath] = FileInfo{Size: info.Size(), Hash: calcFileHash(path), Type: fileref.FILE}
fileUpdatedAt := common.Timestamp(info.ModTime().Unix())
fMap[lPath] = FileInfo{Size: info.Size(), Hash: calcFileHash(path), Type: fileref.FILE, UpdatedAt: fileUpdatedAt}
}
return nil
}
Expand Down Expand Up @@ -204,7 +205,8 @@ func findDelta(rMap map[string]FileInfo, lMap map[string]FileInfo, prevMap map[s
for lFile, lInfo := range lMap {
if pm, ok := rMap[lFile]; ok {
// Local file existed in previous sync also
if pm.Hash != lInfo.Hash {
//somehow hash check is inaccurate hence adding updatedAt check also
if pm.Hash != lInfo.Hash && pm.UpdatedAt != lInfo.UpdatedAt{
// File modified in local
lMod[lFile] = lInfo
}
Expand Down

0 comments on commit 7ec29ad

Please sign in to comment.