From 5e88b6766daf1bd9cd04222323ad2638d736ed42 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Aug 2024 11:01:01 -0400 Subject: [PATCH] added limit flag for compression and decompression --- nut/Config.py | 2 ++ nut/__init__.py | 26 ++++++++++++++++++++++++++ requirements.txt | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/nut/Config.py b/nut/Config.py index eaf809f81..7cf91852b 100644 --- a/nut/Config.py +++ b/nut/Config.py @@ -20,6 +20,8 @@ autoUpdateTitleDb = True allowNoMetadata = True cdnCacheOnly = False +limit = 0 +limitCount = 0 region = None diff --git a/nut/__init__.py b/nut/__init__.py index 65f22e810..a2130d1fd 100644 --- a/nut/__init__.py +++ b/nut/__init__.py @@ -280,6 +280,7 @@ def compress(filePath, compressionLevel=19, outputDir=None, copy = False): f.write(buffer) newNsp.close() + container.close() if copy: os.unlink(tmpFilePath) @@ -367,6 +368,12 @@ def compressAll(level=19, copy = False): if Config.download.fileSizeMin is not None and lastestNsp.getFileSize() < Config.download.fileSizeMin: continue + if Config.limit: + Config.limitCount += 1 + + if Config.limitCount > Config.limit: + continue + q.put(lastestNsp.path) except BaseException as e: @@ -455,6 +462,12 @@ def decompressAll(): if Config.download.fileSizeMin is not None and lastestNsz.getFileSize() < Config.download.fileSizeMin: continue + if Config.limit: + Config.limitCount += 1 + + if Config.limitCount > Config.limit: + continue + q.put(lastestNsz.path) except BaseException as e: @@ -775,6 +788,13 @@ def _ftpsync(url): if path[-3:] == 'nsx': if len(Titles.get(nsp.titleId).getFiles('nsp')) or len(Titles.get(nsp.titleId).getFiles('nsz')): continue + + if Config.limit: + Config.limitCount += 1 + + if Config.limitCount > Config.limit: + continue + q.put(nsp) except BaseException as e: Print.error(str(e)) @@ -1269,6 +1289,12 @@ def extractNcaMeta(files = []): if hasCnmt(nsp.titleId, nsp.version): continue + if Config.limit: + Config.limitCount += 1 + + if Config.limitCount > Config.limit: + continue + q[path] = nsp except BaseException: Print.info('exception: %s' % (path)) diff --git a/requirements.txt b/requirements.txt index 1c7bc2b20..eaa52a1b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ pycryptodome~=3.14.1 pycryptoplus~=0.0.1 pyopenssl~=22.0.0 Flask~=2.0.3 -Pillow~=9.0.1 +Pillow~=10.4.0 zstandard==0.15.2 future~=0.18.2 asn1~=2.4.2