Skip to content

Commit a5a1602

Browse files
committed
Merge branch 'master' into zstd-long-distance-mode
2 parents 25a6291 + 2d3ab4b commit a5a1602

9 files changed

+26
-16
lines changed

nsz/FileExistingChecks.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,14 @@ def fileNameCheck(filePath, targetFileExtension, filesAtTarget, removeOld, overw
153153
'If you want to overwrite it use the -w parameter!'.format(Path(filePath).name))
154154
return False
155155

156-
def delete_source_file(source_file_path):
157-
if Path(source_file_path).exists():
158-
Print.info("Deleting source file {0}".format(source_file_path))
159-
remove(source_file_path)
156+
def delete_source_file(source_file_path, outFolder):
157+
filePath = Path(source_file_path)
158+
if filePath.exists():
159+
resultFile = Path(targetExtension(outFolder.joinpath(filePath.name)))
160+
if resultFile.exists():
161+
Print.info("[DELETING] Source file {0}".format(source_file_path))
162+
remove(source_file_path)
163+
else:
164+
Print.warning("[WARNING] Skipped deleting source file because target file doesn't exist")
160165
else:
161-
Print.warning("{0} was already removed.".format(source_file_path))
166+
Print.warning("[WARNING] {0} was already removed.".format(source_file_path))

nsz/IndependentNczDecompressor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ def __decompressNcz(nspf, f):
108108
inputChunk = decompressor.read(chunkSz)
109109
if not len(inputChunk):
110110
break
111-
if not useBlockCompression:
112-
decompressor.flush()
113111
if s.cryptoType in (3, 4):
114112
inputChunk = crypto.encrypt(inputChunk)
115113
f.write(inputChunk)

nsz/NszDecompressor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ def __decompressNcz(nspf, f, statusReportInfo, pleaseNoPrint):
162162
inputChunk = blockDecompressorReader.read(chunkSz)
163163
else:
164164
inputChunk = decompressor.read(chunkSz)
165-
decompressor.flush()
166165
if not len(inputChunk):
167166
break
168167
if useCrypto:

nsz/PathTools.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ def isXciXcz(filePath):
3636
def changeExtension(filePath, newExtension):
3737
return str(filePath.parent.resolve().joinpath(filePath.stem + newExtension))
3838

39+
def targetExtension(filePath):
40+
if filePath.suffix == '.nsp': newExtension = '.nsz'
41+
if filePath.suffix == '.xci': newExtension = '.xcz'
42+
if filePath.suffix == '.nca': newExtension = '.ncz'
43+
if filePath.suffix == '.nsz': newExtension = '.nsp'
44+
if filePath.suffix == '.xcz': newExtension = '.xci'
45+
if filePath.suffix == '.ncz': newExtension = '.nca'
46+
return str(filePath.parent.resolve().joinpath(filePath.stem + newExtension))
47+
3948
def getExtensionName(filePath):
4049
return str(Path(filePath).suffix[1:].upper())
4150

nsz/SolidCompressor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def processContainer(readContainer, writeContainer, compressionLevel, useLongDis
106106
partitions[partNr] = None
107107

108108
compressor.flush(FLUSH_FRAME)
109-
compressor.flush(COMPRESSOBJ_FLUSH_FINISH)
110109
statusReport[id] = [nspf.tell(), f.tell(), nspf.size, 'Compressing']
111110

112111
written = f.tell() - start

nsz/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def main():
217217
barManager.stop()
218218

219219
for filePath in sourceFileToDelete:
220-
delete_source_file(filePath)
220+
delete_source_file(filePath, outFolder)
221221

222222
if args.D:
223223
for f_str in args.file:
@@ -228,12 +228,12 @@ def main():
228228
outFolder = argOutFolder if argOutFolder else filePath.parent.absolute()
229229
if filePath.suffix == '.nsz':
230230
if not outFolder in targetDictNsz:
231-
targetDictNsz[outFolder] = CreateTargetDict(outFolder, args, ".xcz")
231+
targetDictNsz[outFolder] = CreateTargetDict(outFolder, args, ".nsp")
232232
if not AllowedToWriteOutfile(filePath, ".nsp", targetDictNsz[outFolder], args):
233233
continue
234234
elif filePath.suffix == '.xcz':
235235
if not outFolder in targetDictXcz:
236-
targetDictXcz[outFolder] = CreateTargetDict(outFolder, args, ".xcz")
236+
targetDictXcz[outFolder] = CreateTargetDict(outFolder, args, ".xci")
237237
if not AllowedToWriteOutfile(filePath, ".xci", targetDictXcz[outFolder], args):
238238
continue
239239
elif filePath.suffix == '.ncz':
@@ -244,7 +244,7 @@ def main():
244244
continue
245245
decompress(filePath, outFolder)
246246
if args.rm_source:
247-
delete_source_file(filePath)
247+
delete_source_file(filePath, outFolder)
248248
except KeyboardInterrupt:
249249
raise
250250
except BaseException as e:

requirements-gui.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pycryptodome
2-
zstandard
2+
zstandard==0.15.2
33
enlighten
44
pywin32;platform_system == "Windows"
55
pypiwin32;platform_system == "Windows"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pycryptodome
2-
zstandard
2+
zstandard==0.15.2
33
enlighten

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
install_requires=[
2525
'pycryptodome',
26-
'zstandard',
26+
'zstandard==0.15.2',
2727
'enlighten',
2828
],
2929
extras_require={

0 commit comments

Comments
 (0)