mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-30 19:52:28 +08:00
feat(edit-docs): remove input file
This commit is contained in:
parent
ba17ce8616
commit
09c081fdcf
@ -78,17 +78,22 @@ function importData(input: Buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createImportZip() {
|
async function createImportZip() {
|
||||||
|
const inputFile = "input.zip";
|
||||||
const archive = archiver("zip", {
|
const archive = archiver("zip", {
|
||||||
zlib: { level: 0 }
|
zlib: { level: 0 }
|
||||||
});
|
});
|
||||||
|
|
||||||
archive.directory(destRootPath, "/");
|
archive.directory(destRootPath, "/");
|
||||||
|
|
||||||
const outputStream = fsExtra.createWriteStream("input.zip");
|
const outputStream = fsExtra.createWriteStream(inputFile);
|
||||||
archive.pipe(outputStream);
|
archive.pipe(outputStream);
|
||||||
await waitForEnd(archive, outputStream);
|
await waitForEnd(archive, outputStream);
|
||||||
|
|
||||||
return await fsExtra.readFile("input.zip");
|
try {
|
||||||
|
return await fsExtra.readFile(inputFile);
|
||||||
|
} finally {
|
||||||
|
await fsExtra.rm(inputFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForEnd(archive: Archiver, stream: WriteStream) {
|
function waitForEnd(archive: Archiver, stream: WriteStream) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user