View | Details | Raw Unified | Return to bug 272071 | Differences between
and this patch

Collapse All | Expand All

(-)b/news/sabnzbd/Makefile (-2 / +2 lines)
Lines 1-5 Link Here
1
PORTNAME=	sabnzbd
1
PORTNAME=	sabnzbd
2
DISTVERSION=	4.0.0
2
DISTVERSION=	4.0.2
3
CATEGORIES=	news
3
CATEGORIES=	news
4
MASTER_SITES=	https://github.com/sabnzbd/sabnzbd/releases/download/${DISTVERSION}/
4
MASTER_SITES=	https://github.com/sabnzbd/sabnzbd/releases/download/${DISTVERSION}/
5
DISTNAME=	SABnzbd-${DISTVERSION}-src
5
DISTNAME=	SABnzbd-${DISTVERSION}-src
Lines 19-25 RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}cheetah3>=0:devel/py-cheetah3@${PY_FLAVOR} \ Link Here
19
		${PYTHON_PKGNAMEPREFIX}feedparser>=6.0.0:textproc/py-feedparser@${PY_FLAVOR} \
19
		${PYTHON_PKGNAMEPREFIX}feedparser>=6.0.0:textproc/py-feedparser@${PY_FLAVOR} \
20
		${PYTHON_PKGNAMEPREFIX}portend>=0:net/py-portend@${PY_FLAVOR} \
20
		${PYTHON_PKGNAMEPREFIX}portend>=0:net/py-portend@${PY_FLAVOR} \
21
		${PYTHON_PKGNAMEPREFIX}sqlite3>=0:databases/py-sqlite3@${PY_FLAVOR} \
21
		${PYTHON_PKGNAMEPREFIX}sqlite3>=0:databases/py-sqlite3@${PY_FLAVOR} \
22
		${PYTHON_PKGNAMEPREFIX}sabctools>=0:news/py-sabctools@${PY_FLAVOR} \
22
		 ${PYTHON_PKGNAMEPREFIX}sabctools>=7.1.0<7.1.0_99:news/py-sabctools@${PY_FLAVOR} \
23
		${PYTHON_PKGNAMEPREFIX}guessit>0:multimedia/py-guessit@${PY_FLAVOR} \
23
		${PYTHON_PKGNAMEPREFIX}guessit>0:multimedia/py-guessit@${PY_FLAVOR} \
24
		${PYTHON_PKGNAMEPREFIX}puremagic>0:sysutils/py-puremagic@${PY_FLAVOR} \
24
		${PYTHON_PKGNAMEPREFIX}puremagic>0:sysutils/py-puremagic@${PY_FLAVOR} \
25
		${PYTHON_PKGNAMEPREFIX}pysocks>0:net/py-pysocks@${PY_FLAVOR} \
25
		${PYTHON_PKGNAMEPREFIX}pysocks>0:net/py-pysocks@${PY_FLAVOR} \
(-)b/news/sabnzbd/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1682683069
1
TIMESTAMP = 1687133196
2
SHA256 (SABnzbd-4.0.0-src.tar.gz) = 32e6073a238d25747ef86919ff0804725cf59ddbcfab60c812e21c998ce2ed71
2
SHA256 (SABnzbd-4.0.2-src.tar.gz) = 2783f225057031869dff74f7eb191f54f35e8abe60906fcaaa94ab7772166c4e
3
SIZE (SABnzbd-4.0.0-src.tar.gz) = 5079964
3
SIZE (SABnzbd-4.0.2-src.tar.gz) = 5081392
(-)b/news/sabnzbd/files/patch-requirements.txt (+10 lines)
Added Link Here
1
--- requirements.txt.orig	2023-06-07 19:24:42 UTC
2
+++ requirements.txt
3
@@ -1,6 +1,6 @@
4
 # Main requirements
5
 # Note that not all sub-dependencies are listed, but only ones we know could cause trouble
6
-sabctools==7.0.2
7
+sabctools==7.1.0
8
 cheetah3==3.2.6.post1
9
 cffi==1.15.1
10
 pycparser==2.21
(-)b/news/sabnzbd/files/patch-sabnzbd_assembler.py (+63 lines)
Added Link Here
1
--- sabnzbd/assembler.py.orig	2023-06-07 19:24:42 UTC
2
+++ sabnzbd/assembler.py
3
@@ -27,6 +27,7 @@ from threading import Thread
4
 import ctypes
5
 from typing import Tuple, Optional, List
6
 
7
+import sabctools
8
 import sabnzbd
9
 from sabnzbd.misc import get_all_passwords, match_str
10
 from sabnzbd.filesystem import (
11
@@ -160,13 +161,21 @@ class Assembler(Thread):
12
 
13
     @staticmethod
14
     def assemble(nzo: NzbObject, nzf: NzbFile, file_done: bool):
15
-        """Assemble a NZF from its table of articles
16
-        1) Partial write: write what we have
17
-        2) Nothing written before: write all
18
-        """
19
+        """Assemble a NZF from its table of articles"""
20
 
21
+        # When a file exists, we cannot use "w+b"
22
+        if os.path.exists(nzf.filepath):
23
+            open_mode = "r+b"
24
+            file_sparse = True
25
+        else:
26
+            open_mode = "w+b"
27
+            file_sparse = False
28
+
29
         # We write large article-sized chunks, so we can safely skip the buffering of Python
30
-        with open(nzf.filepath, "ab", buffering=0) as fout:
31
+        with open(nzf.filepath, open_mode, buffering=0) as fout:
32
+            # Track position, so we can prevent a seek if writing continuous
33
+            file_position = 0
34
+
35
             for article in nzf.decodetable:
36
                 # Break if deleted during writing
37
                 if nzo.status is Status.DELETED:
38
@@ -178,9 +187,25 @@ class Assembler(Thread):
39
 
40
                 # Write all decoded articles
41
                 if article.decoded:
42
+                    # On first write try to make the file sparse
43
+                    if not file_sparse and article.file_size is not None and article.file_size > 0:
44
+                        file_sparse = True
45
+                        try:
46
+                            sabctools.sparse(fout, article.file_size)
47
+                        except:
48
+                            logging.debug("Failed to make %s sparse with length %d", nzf.filepath, article.file_size)
49
+                            logging.debug("Traceback: ", exc_info=True)
50
+
51
                     data = sabnzbd.ArticleCache.load_article(article)
52
                     # Could be empty in case nzo was deleted
53
                     if data:
54
+                        if article.data_begin is not None:
55
+                            # Seek ahead if needed
56
+                            if article.data_begin != file_position:
57
+                                fout.seek(article.data_begin)
58
+                            file_position = article.data_begin + len(data)
59
+                        else:
60
+                            fout.seek(0, os.SEEK_END)
61
                         fout.write(data)
62
                         nzf.update_crc32(article.crc32, len(data))
63
                         article.on_disk = True
(-)b/news/sabnzbd/files/patch-sabnzbd_constants.py (+11 lines)
Added Link Here
1
--- sabnzbd/constants.py.orig	2023-06-07 19:24:42 UTC
2
+++ sabnzbd/constants.py
3
@@ -49,7 +49,7 @@ RENAMES_FILE = "__renames__"
4
 ATTRIB_FILE = "SABnzbd_attrib"
5
 REPAIR_REQUEST = "repair-all.sab"
6
 
7
-SABCTOOLS_VERSION_REQUIRED = "7.0.2"
8
+SABCTOOLS_VERSION_REQUIRED = "7.1.0"
9
 
10
 DB_HISTORY_VERSION = 1
11
 DB_HISTORY_NAME = "history%s.db" % DB_HISTORY_VERSION
(-)b/news/sabnzbd/files/patch-sabnzbd_decoder.py (+11 lines)
Added Link Here
1
--- sabnzbd/decoder.py.orig	2023-06-07 19:24:42 UTC
2
+++ sabnzbd/decoder.py
3
@@ -172,7 +172,7 @@ def decode(article: Article, raw_data: bytearray):
4
 
5
 def decode_yenc(article: Article, data: bytearray) -> bytearray:
6
     # Let SABCTools do all the heavy lifting
7
-    yenc_filename, article.data_begin, article.data_size, crc_correct = sabctools.yenc_decode(data)
8
+    yenc_filename, article.file_size, article.data_begin, article.data_size, crc_correct = sabctools.yenc_decode(data)
9
 
10
     nzf = article.nzf
11
     # Assume it is yenc
(-)b/news/sabnzbd/files/patch-sabnzbd_nzbstuff.py (+18 lines)
Added Link Here
1
--- sabnzbd/nzbstuff.py.orig	2023-06-07 19:24:42 UTC
2
+++ sabnzbd/nzbstuff.py
3
@@ -163,6 +163,7 @@ ArticleSaver = (
4
     "bytes",
5
     "lowest_partnum",
6
     "decoded",
7
+    "file_size",
8
     "data_begin",
9
     "data_size",
10
     "on_disk",
11
@@ -187,6 +188,7 @@ class Article(TryList):
12
         self.fetcher_priority: int = 0
13
         self.tries: int = 0  # Try count
14
         self.decoded: bool = False
15
+        self.file_size: Optional[int] = None
16
         self.data_begin: Optional[int] = None
17
         self.data_size: Optional[int] = None
18
         self.on_disk: bool = False

Return to bug 272071