summaryrefslogtreecommitdiff
path: root/pkg/transmission/patch/0002-Choose-larger-pieces-for-larger-sizes.patch
blob: a984c29ea697a6fb3ecfc92aa4b13fc7f8ff73c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From ed525431bbe23d61c4c8dd4664c13bc19b4db889 Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Mon, 24 Apr 2023 21:09:06 -0700
Subject: [PATCH] Choose larger pieces for larger sizes

---
 libtransmission/makemeta.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/libtransmission/makemeta.c b/libtransmission/makemeta.c
index 713f3e5cb..ae422395d 100644
--- a/libtransmission/makemeta.c
+++ b/libtransmission/makemeta.c
@@ -88,9 +88,24 @@ static struct FileList* getFiles(char const* dir, char const* base, struct FileL
 
 static uint32_t bestPieceSize(uint64_t totalSize)
 {
-    uint32_t const KiB = 1024;
-    uint32_t const MiB = 1048576;
-    uint32_t const GiB = 1073741824;
+    uint64_t const KiB = 1024;
+    uint64_t const MiB = 1048576;
+    uint64_t const GiB = 1073741824;
+
+    if (totalSize >= 16 * GiB)
+    {
+        return 16 * MiB;
+    }
+
+    if (totalSize >= 8 * GiB)
+    {
+        return 8 * MiB;
+    }
+
+    if (totalSize >= 4 * GiB)
+    {
+        return 4 * MiB;
+    }
 
     if (totalSize >= 2 * GiB)
     {
-- 
2.37.3