Export not unzipped?
fortran01 opened this issue Β· comments
Did I miss anything? It's the ZIP file that is committed. I have to do the following to unzip. ππ½
# Find the zip file using the wildcard
zip_file="$(ls *.zip | head -n1)"
# Unzip the file
unzip "$zip_file"
# Get the top-level folder
folder=$(unzip -Z1 "$zip_file" | awk -F/ '{print $1}' | sort | uniq)
# Move the contents of the first-level folder to the current directory
rsync "${folder%/}"/* .
# Remove the first-level folder
rm -r "${folder%/}"
# Delete the zip file
rm "$zip_file"
Have you altered the script in some way? Usually these two lines extract the .zip and remove it afterwards:
// ...
await extract(workspaceZip, { dir: workspaceDir });
await unlink(workspaceZip);
// ...
Also workspace.zip
is in the .gitignore
which prevents it from being committed.
Edit: I suspect this might be because of #10 β I'll have a look at it.
No modifications. I have to do above, so I can unzip it. Some observations:
- my output file is less than 500MB
- the file name is not workspace.zip, it's some hash
Thanks for checking.
I encountered the same issue
I believe the reason is that when calling notion exportURL, it returns a zip package. The exportFromNotion
function compresses the zip package again.
const stream = response.data.pipe(createWriteStream(destination));
My solution is to use the onEntry property of extract to detect and unzip the zip package again. The code looks like this:
await extract(workspaceZip, {
dir: workspaceDir, onEntry: async (entry, zipfile) => {
if (entry.fileName.toLowerCase().endsWith('.zip')) {
const nestedZipFile = join(workspaceDir, entry.fileName);
zipfile.openReadStream(entry, (err, readStream) => {
if (err) throw err;
const writeStream = createWriteStream(nestedZipFile);
readStream.pipe(writeStream);
writeStream.on('finish', () => {
extract(nestedZipFile, { dir: workspaceDir })
});
});
}
}
});