modifyListing will modify the listing based on the results of the sync
(ctx context.Context, src fs.Fs, dst fs.Fs, results []Results, queues queues, is1to2 bool)
| 457 | |
| 458 | // modifyListing will modify the listing based on the results of the sync |
| 459 | func (b *bisyncRun) modifyListing(ctx context.Context, src fs.Fs, dst fs.Fs, results []Results, queues queues, is1to2 bool) (err error) { |
| 460 | queue := queues.copy2to1 |
| 461 | direction := "2to1" |
| 462 | if is1to2 { |
| 463 | queue = queues.copy1to2 |
| 464 | direction = "1to2" |
| 465 | } |
| 466 | |
| 467 | fs.Debugf(nil, "updating %s", direction) |
| 468 | prettyprint(results, "results", fs.LogLevelDebug) |
| 469 | prettyprint(queue, "queue", fs.LogLevelDebug) |
| 470 | |
| 471 | srcListing, dstListing := b.getListingNames(is1to2) |
| 472 | srcList, err := b.loadListing(srcListing) |
| 473 | if err != nil { |
| 474 | return fmt.Errorf("cannot read prior listing: %w", err) |
| 475 | } |
| 476 | dstList, err := b.loadListing(dstListing) |
| 477 | if err != nil { |
| 478 | return fmt.Errorf("cannot read prior listing: %w", err) |
| 479 | } |
| 480 | // set list hash type |
| 481 | if b.opt.Resync && !b.opt.IgnoreListingChecksum { |
| 482 | if is1to2 { |
| 483 | srcList.hash = b.opt.Compare.HashType1 |
| 484 | dstList.hash = b.opt.Compare.HashType2 |
| 485 | } else { |
| 486 | srcList.hash = b.opt.Compare.HashType2 |
| 487 | dstList.hash = b.opt.Compare.HashType1 |
| 488 | } |
| 489 | if b.opt.Compare.DownloadHash && srcList.hash == hash.None { |
| 490 | srcList.hash = hash.MD5 |
| 491 | } |
| 492 | if b.opt.Compare.DownloadHash && dstList.hash == hash.None { |
| 493 | dstList.hash = hash.MD5 |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | b.debugFn(b.DebugName, func() { |
| 498 | var rs ResultsSlice = results |
| 499 | b.debug(b.DebugName, fmt.Sprintf("modifyListing direction: %s, results has name?: %v", direction, rs.has(b.DebugName))) |
| 500 | b.debug(b.DebugName, fmt.Sprintf("modifyListing direction: %s, srcList has name?: %v, dstList has name?: %v", direction, srcList.has(b.DebugName), dstList.has(b.DebugName))) |
| 501 | }) |
| 502 | |
| 503 | srcWinners := newFileList() |
| 504 | dstWinners := newFileList() |
| 505 | errors := newFileList() |
| 506 | ctxRecheck, filterRecheck := filter.AddConfig(ctx) |
| 507 | |
| 508 | for _, result := range results { |
| 509 | if result.Name == "" { |
| 510 | continue |
| 511 | } |
| 512 | |
| 513 | if result.AltName != "" { |
| 514 | b.aliases.Add(result.Name, result.AltName) |
| 515 | } |
| 516 |
no test coverage detected