From a21f7561ab94d1cc07b699eaf51cf2e016dc44b7 Mon Sep 17 00:00:00 2001 From: Alex Sharov <AskAlexSharov@gmail.com> Date: Thu, 24 Mar 2022 12:26:22 +0700 Subject: [PATCH] Snapshots: gen .torrent file only for big segments #3761 (#3761) --- cmd/downloader/downloader/util.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/downloader/downloader/util.go b/cmd/downloader/downloader/util.go index 57e2b709a7..24c0ed8c4d 100644 --- a/cmd/downloader/downloader/util.go +++ b/cmd/downloader/downloader/util.go @@ -87,6 +87,13 @@ func allSegmentFiles(dir string) ([]string, error) { // BuildTorrentFileIfNeed - create .torrent files from .seg files (big IO) - if .seg files were added manually func BuildTorrentFileIfNeed(ctx context.Context, originalFileName string, root *dir.Rw) (err error) { + f, err := snapshotsync.ParseFileName(root.Path, originalFileName) + if err != nil { + return err + } + if f.To-f.From != snapshotsync.DEFAULT_SEGMENT_SIZE { + return nil + } torrentFilePath := filepath.Join(root.Path, originalFileName+".torrent") if _, err := os.Stat(torrentFilePath); err != nil { if !errors.Is(err, os.ErrNotExist) { -- GitLab