From 3dd109c6d910528de18d4edaedd9c4599fc4d328 Mon Sep 17 00:00:00 2001 From: laqieer Date: Tue, 15 Mar 2022 21:08:19 +0800 Subject: [PATCH 1/3] fix the glitch that cut the end of the file if it's larger than the changed file patch was originally created with --- js/formats/ups.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/formats/ups.js b/js/formats/ups.js index 39eecc4..07a81f1 100644 --- a/js/formats/ups.js +++ b/js/formats/ups.js @@ -57,6 +57,11 @@ UPS.prototype.apply=function(romFile, validate){ throw new Error('error_crc_input'); } + /* fix the glitch that cut the end of the file if it's larger than the changed file patch was originally created with */ + sizeOutput = this.sizeOutput + if(!validate && sizeOutput < this.sizeInput){ + sizeOutput = this.sizeInput + } /* copy original file */ tempFile=new MarcFile(this.sizeOutput); @@ -201,4 +206,4 @@ function createUPSFromFiles(original, modified){ patch.checksumInput=crc32(original); patch.checksumOutput=crc32(modified); return patch -} \ No newline at end of file +} From 98aa4f3580135c4731f8ca888c6a4f466460682b Mon Sep 17 00:00:00 2001 From: laqieer Date: Tue, 15 Mar 2022 21:16:53 +0800 Subject: [PATCH 2/3] fix: fix the glitch that cut the end of the file if it's larger than the changed file patch was originally created with --- js/formats/ups.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/formats/ups.js b/js/formats/ups.js index 07a81f1..c48a0d9 100644 --- a/js/formats/ups.js +++ b/js/formats/ups.js @@ -64,7 +64,7 @@ UPS.prototype.apply=function(romFile, validate){ } /* copy original file */ - tempFile=new MarcFile(this.sizeOutput); + tempFile=new MarcFile(sizeOutput); romFile.copyToFile(tempFile, 0, this.sizeInput); romFile.seek(0); From 367cdfe4fe5ea0d818dc6ef53d72400057fdc23a Mon Sep 17 00:00:00 2001 From: laqieer Date: Tue, 15 Mar 2022 21:38:50 +0800 Subject: [PATCH 3/3] fix: fix the glitch that cut the end of the file if it's larger than the changed file patch was originally created with --- js/formats/ups.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/formats/ups.js b/js/formats/ups.js index c48a0d9..b7115ff 100644 --- a/js/formats/ups.js +++ b/js/formats/ups.js @@ -59,13 +59,17 @@ UPS.prototype.apply=function(romFile, validate){ /* fix the glitch that cut the end of the file if it's larger than the changed file patch was originally created with */ sizeOutput = this.sizeOutput - if(!validate && sizeOutput < this.sizeInput){ - sizeOutput = this.sizeInput + sizeInput = this.sizeInput + if(!validate && sizeInput < romFile.fileSize){ + sizeInput = romFile.fileSize + if(sizeOutput < sizeInput){ + sizeOutput = sizeInput + } } /* copy original file */ tempFile=new MarcFile(sizeOutput); - romFile.copyToFile(tempFile, 0, this.sizeInput); + romFile.copyToFile(tempFile, 0, sizeInput); romFile.seek(0);