@@ -369,12 +369,14 @@ const isSkipItem = (
369
369
}
370
370
}
371
371
}
372
+ if ( watchDir && ! key . startsWith ( watchDir ) ) {
373
+ return true ;
374
+ }
375
+
372
376
if ( syncConfigDir && isInsideObsFolder ( key , configDir ) ) {
373
377
return false ;
374
378
}
375
- if ( ! key . startsWith ( watchDir ) ) {
376
- return true ;
377
- }
379
+
378
380
return (
379
381
isHiddenPath ( key , true , false ) ||
380
382
( ! syncUnderscoreItems && isHiddenPath ( key , false , true ) ) ||
@@ -386,6 +388,8 @@ const isSkipItem = (
386
388
const ensembleMixedStates = async (
387
389
remoteStates : FileOrFolderMixedState [ ] ,
388
390
local : TAbstractFile [ ] ,
391
+ vault : Vault ,
392
+ recentSyncedFiles : any ,
389
393
selectedMode : boolean ,
390
394
selectedLocalFilePaths : string [ ] | undefined ,
391
395
localConfigDirContents : ObsConfigDirFileType [ ] | undefined ,
@@ -417,7 +421,21 @@ const ensembleMixedStates = async (
417
421
// ignore
418
422
continue ;
419
423
} else if ( entry instanceof TFile ) {
420
- const mtimeLocal = Math . max ( entry . stat . mtime ?? 0 , entry . stat . ctime ?? 0 ) ;
424
+ let mtimeLocal = Math . max ( entry . stat . mtime ?? 0 , entry . stat . ctime ?? 0 ) ;
425
+
426
+ const snap = recentSyncedFiles && recentSyncedFiles [ entry . path ] ;
427
+ if ( snap ) {
428
+ log . info ( 'snap found: ' , snap ) ;
429
+ const curContents = await vault . read ( entry ) ;
430
+ if ( entry . stat . size === snap . size ) {
431
+ if ( curContents === snap . contents ) {
432
+ log . info ( 'current contents same with last sync, not changed' ) ;
433
+ mtimeLocal = snap . mtime ;
434
+ }
435
+ } else {
436
+ log . info ( 'current contents changed' ) ;
437
+ }
438
+ }
421
439
r = {
422
440
key : entry . path ,
423
441
existLocal : true ,
@@ -1010,6 +1028,7 @@ const SIZES_GO_WRONG_DECISIONS: Set<DecisionType> = new Set([
1010
1028
export const getSyncPlan = async (
1011
1029
remoteStates : FileOrFolderMixedState [ ] ,
1012
1030
local : TAbstractFile [ ] ,
1031
+ recentSyncedFiles : any ,
1013
1032
selectedMode : boolean , // Selected mode only care about files in selectedLocalFilePaths
1014
1033
selectedLocalFilePaths : string [ ] | undefined , // Only care file in this list and ignore all other files, work when selectedMode is true
1015
1034
localConfigDirContents : ObsConfigDirFileType [ ] | undefined ,
@@ -1028,6 +1047,8 @@ export const getSyncPlan = async (
1028
1047
const mixedStates = await ensembleMixedStates (
1029
1048
remoteStates ,
1030
1049
local ,
1050
+ vault ,
1051
+ recentSyncedFiles ,
1031
1052
selectedMode ,
1032
1053
selectedLocalFilePaths ,
1033
1054
localConfigDirContents ,
0 commit comments