🎨 Even for newly added files, use .tmp file extension

This commit is contained in:
C-3PO 2018-09-14 06:37:51 +02:00
parent 110be7f94c
commit 69759e5709
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -83,13 +83,20 @@ export default async function getPatch({ product, from, to, sourceDirectory, tar
try {
//create file write stream
const outputName = path.join(targetDir, file.name);
await createDirRecursively(path.dirname(outputName));
const outputStream = fs.createWriteStream(outputName);
const outputNameTemp = path.join(targetDir, `${file.name}.tmp`);
await createDirRecursively(path.dirname(outputNameTemp));
const outputStream = fs.createWriteStream(outputNameTemp);
//start installation
await launch(diskFilenames[file.diskNumberStart], file.offset, file.compressedSize, file.decryptionKeys, undefined, outputStream);
outputStream.close();
fs.rename(outputNameTemp, outputName, (renameError) => {
if (renameError) {
throw new Error(`Could not rename output file "${outputNameTemp}": ${renameError.name}`);
}
});
} catch (error) {
console.error(`Could not extract file "${file.name}"`, error);
}