Procházet zdrojové kódy

:art: 优化云端同步上传资源占用和耗时 https://github.com/siyuan-note/siyuan/issues/5093

Liang Ding před 3 roky
rodič
revize
7f5ddc5838
1 změnil soubory, kde provedl 8 přidání a 7 odebrání
  1. 8 7
      kernel/model/osssync.go

+ 8 - 7
kernel/model/osssync.go

@@ -802,21 +802,22 @@ func localUpsertRemoveListOSS(localDirPath string, cloudFileList map[string]*Clo
 			return nil
 		}
 
-		// TODO: 优化云端同步上传资源占用和耗时 https://github.com/siyuan-note/siyuan/issues/5093
+		if 0 < cloudIdx.Updated {
+			// 优先使用时间戳校验
+			if localModTime := info.ModTime().Unix(); cloudIdx.Updated == localModTime {
+				unchanged[relPath] = true
+				return nil
+			}
+		}
+
 		localHash, hashErr := util.GetEtag(path)
 		if nil != hashErr {
 			err = hashErr
 			return io.EOF
 		}
-
 		if cloudIdx.Hash == localHash {
 			unchanged[relPath] = true
 		}
-
-		//localModTime := info.ModTime().Unix()
-		//if cloudIdx.Updated == localModTime {
-		//	unchanged[relPath] = true
-		//}
 		return nil
 	})