(fileInformation *FileInformation, strategy latest.InitialSyncStrategy)
| 388 | ) |
| 389 | |
| 390 | func (i *initialSyncer) decide(fileInformation *FileInformation, strategy latest.InitialSyncStrategy) action { |
| 391 | // Exclude if stat is nil |
| 392 | if fileInformation == nil { |
| 393 | return downloadAction |
| 394 | } |
| 395 | |
| 396 | // Exclude local symlinks |
| 397 | if fileInformation.IsSymbolicLink { |
| 398 | return noAction |
| 399 | } |
| 400 | |
| 401 | // Exclude changes on the exclude list |
| 402 | if i.o.IgnoreMatcher != nil { |
| 403 | if i.o.IgnoreMatcher.Matches(fileInformation.Name, fileInformation.IsDirectory) { |
| 404 | return noAction |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // Check if we already tracked the path |
| 409 | if i.o.FileIndex.fileMap[fileInformation.Name] != nil { |
| 410 | // Folder already exists, don't send change |
| 411 | if fileInformation.IsDirectory { |
| 412 | return noAction |
| 413 | } |
| 414 | |
| 415 | // Exclude symlinks |
| 416 | if i.o.FileIndex.fileMap[fileInformation.Name].IsSymbolicLink { |
| 417 | return noAction |
| 418 | } |
| 419 | |
| 420 | // File did not change or was changed by downstream |
| 421 | if fileInformation.Size == i.o.FileIndex.fileMap[fileInformation.Name].Size { |
| 422 | if strategy == latest.InitialSyncStrategyPreferLocal && !equalFilePermissions(fileInformation.Mode, i.o.FileIndex.fileMap[fileInformation.Name].Mode) { |
| 423 | return uploadAction |
| 424 | } |
| 425 | |
| 426 | if fileInformation.Mtime == i.o.FileIndex.fileMap[fileInformation.Name].Mtime { |
| 427 | return noAction |
| 428 | } else if i.o.CompareBy == latest.InitialSyncCompareBySize { |
| 429 | return noAction |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | // Okay we have a conflict so now we decide based on the given strategy |
| 434 | switch strategy { |
| 435 | case latest.InitialSyncStrategyPreferLocal: |
| 436 | return uploadAction |
| 437 | case latest.InitialSyncStrategyPreferRemote: |
| 438 | return downloadAction |
| 439 | case latest.InitialSyncStrategyPreferNewest: |
| 440 | if fileInformation.Mtime == i.o.FileIndex.fileMap[fileInformation.Name].Mtime { |
| 441 | return noAction |
| 442 | } else if fileInformation.Mtime > i.o.FileIndex.fileMap[fileInformation.Name].Mtime { |
| 443 | return uploadAction |
| 444 | } else { |
| 445 | return downloadAction |
| 446 | } |
| 447 | case latest.InitialSyncStrategyKeepAll: |
no test coverage detected