mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: import: handle error message for invalid zip
This commit is contained in:
1 parent
cb424c9cac
commit
895d50530a
4 files changed
+24
-4
No files matched your search
@@ -15,7 +15,12 @@ fs.ensureDirSync('/tmp/hydro/import-qduoj');
|
||||
|
||||
class ImportQduojHandler extends Handler {
|
||||
async fromFile(domainId: string, zipfile: string) {
|
||||
const zip = new AdmZip(zipfile);
|
||||
let zip: AdmZip;
|
||||
try {
|
||||
zip = new AdmZip(zipfile);
|
||||
} catch (e) {
|
||||
throw new ValidationError('zip', null, e.message);
|
||||
}
|
||||
const tmp = path.resolve(os.tmpdir(), 'hydro', 'import-qduoj', String.random(32));
|
||||
await new Promise((resolve, reject) => {
|
||||
zip.extractAllToAsync(tmp, true, (err) => (err ? reject(err) : resolve(null)));
|
||||
|
||||
Reference in new issue
Block a user