From e99cb0396d235234ec116e1a77c281850b252115 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Sat, 15 Jun 2024 10:04:42 +0700 Subject: [PATCH] save --- erigon-lib/downloader/downloader.go | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/erigon-lib/downloader/downloader.go b/erigon-lib/downloader/downloader.go index 2915fa6ca29..fb44565afe0 100644 --- a/erigon-lib/downloader/downloader.go +++ b/erigon-lib/downloader/downloader.go @@ -330,8 +330,6 @@ func New(ctx context.Context, cfg *downloadercfg.Cfg, logger log.Logger, verbosi d.ctx, d.stopMainLoop = context.WithCancel(ctx) if cfg.AddTorrentsFromDisk { - var downloadMismatches []string - for _, download := range lock.Downloads { if info, err := d.torrentInfo(download.Name); err == nil { if info.Completed != nil { @@ -357,29 +355,15 @@ func New(ctx context.Context, cfg *downloadercfg.Cfg, logger log.Logger, verbosi fileHash := hex.EncodeToString(fileHashBytes) if fileHash != download.Hash && fileHash != hash { - d.logger.Error("[snapshots] download db mismatch", "file", download.Name, "lock", download.Hash, "db", hash, "disk", fileHash, "downloaded", *info.Completed) - downloadMismatches = append(downloadMismatches, download.Name) + d.logger.Debug("[snapshots] download db mismatch", "file", download.Name, "lock", download.Hash, "db", hash, "disk", fileHash, "downloaded", *info.Completed) } else { - d.logger.Warn("[snapshots] lock hash does not match completed download", "file", download.Name, "lock", hash, "download", download.Hash, "downloaded", *info.Completed) + d.logger.Debug("[snapshots] lock hash does not match completed download", "file", download.Name, "lock", hash, "download", download.Hash, "downloaded", *info.Completed) } } } } } - if len(downloadMismatches) > 0 { - return nil, fmt.Errorf("downloaded files have mismatched hashes: %s", strings.Join(downloadMismatches, ",")) - } - - //TODO: why do we need it if we have `addTorrentFilesFromDisk`? what if they are conflict? - //TODO: why it's before `BuildTorrentFilesIfNeed`? what if they are conflict? - //TODO: even if hash is saved in "snapshots-lock.json" - it still must preserve `prohibit_new_downloads.lock` and don't download new files ("user restart" must be fast, "erigon3 has .kv files which never-ending merge and delete small files") - //for _, it := range lock.Downloads { - // if err := d.AddMagnetLink(ctx, snaptype.Hex2InfoHash(it.Hash), it.Name); err != nil { - // return nil, err - // } - //} - if err := d.BuildTorrentFilesIfNeed(d.ctx, lock.Chain, lock.Downloads); err != nil { return nil, err }