mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-26 17:38:20 +01:00
fix: creating missing directories from file paths when they are not specified in zip meta-data
This commit is contained in:
parent
2c64dfe00d
commit
b30a2bb44c
@ -1723,7 +1723,6 @@ namespace OS {
|
|||||||
dest.parent().cache[dest.basename] = this;
|
dest.parent().cache[dest.basename] = this;
|
||||||
return resolve({result: true, error: false});
|
return resolve({result: true, error: false});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(this);
|
|
||||||
return reject(__e(e));
|
return reject(__e(e));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2099,7 +2098,6 @@ namespace OS {
|
|||||||
if (meta.type === "dir") {
|
if (meta.type === "dir") {
|
||||||
const desdir = to.asFileHandle();
|
const desdir = to.asFileHandle();
|
||||||
await desdir.mk(file.basename);
|
await desdir.mk(file.basename);
|
||||||
console.log(desdir, to);
|
|
||||||
const ret = await file.read();
|
const ret = await file.read();
|
||||||
const files = ret.result.map((v: API.FileInfoType) => v.path);
|
const files = ret.result.map((v: API.FileInfoType) => v.path);
|
||||||
if (files.length > 0) {
|
if (files.length > 0) {
|
||||||
@ -2271,17 +2269,26 @@ namespace OS {
|
|||||||
const data = await zfile.asFileHandle().read("binary");
|
const data = await zfile.asFileHandle().read("binary");
|
||||||
const zip = await JSZip.loadAsync(data);
|
const zip = await JSZip.loadAsync(data);
|
||||||
const to = await dest_callback(zip);
|
const to = await dest_callback(zip);
|
||||||
const dirs = [];
|
const dirs = new Set<string>();
|
||||||
const files = [];
|
const files = [];
|
||||||
for (const name in zip.files) {
|
for (const _name in zip.files) {
|
||||||
|
const name = _name.trimFromRight("/");
|
||||||
const file = zip.files[name];
|
const file = zip.files[name];
|
||||||
if (file.dir) {
|
if (file.dir) {
|
||||||
dirs.push(to + "/" + name);
|
dirs.add(to + "/" + name);
|
||||||
} else {
|
} else {
|
||||||
|
const segs = name.split("/");
|
||||||
|
segs.pop();
|
||||||
|
let path = to;
|
||||||
|
for(let seg of segs)
|
||||||
|
{
|
||||||
|
path += "/" + seg;
|
||||||
|
dirs.add(path);
|
||||||
|
}
|
||||||
files.push(name);
|
files.push(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await mkdirAll(dirs, true);
|
await mkdirAll(Array.from(dirs), true);
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
promises.push(new Promise(async (res, rej) => {
|
promises.push(new Promise(async (res, rej) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user