[MIGRATION] - Something happened on the way to heaven

This commit is contained in:
VitoAlbano
2024-08-23 00:00:52 +01:00
parent 76f1c11656
commit 56392615a5
16 changed files with 84 additions and 65 deletions

View File

@@ -53,7 +53,9 @@ export class ClipboardService {
this.document.execCommand('copy');
}
this.notify(message);
} catch {}
} catch {
/* empty */
}
}
}
@@ -76,7 +78,9 @@ export class ClipboardService {
document.execCommand('copy');
}
this.notify(message);
} catch {}
} catch {
/* empty */
}
}
private notify(message) {

View File

@@ -22,36 +22,38 @@ export interface FileInfo {
}
export class FileUtils {
static flatten(folder: any): Promise<FileInfo[]> {
const reader = folder.createReader();
const files: FileInfo[] = [];
return new Promise((resolve) => {
const iterations = [];
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
(function traverse() {
reader.readEntries((entries) => {
if (!entries.length) {
Promise.all(iterations).then(() => resolve(files));
} else {
iterations.push(Promise.all(entries.map((entry) => {
if (entry.isFile) {
return new Promise<void>((resolveFile) => {
entry.file((file: File) => {
files.push({
entry,
file,
relativeFolder: entry.fullPath.replace(/\/[^/]*$/, '')
iterations.push(
Promise.all(
entries.map((entry) => {
if (entry.isFile) {
return new Promise<void>((resolveFile) => {
entry.file((file: File) => {
files.push({
entry,
file,
relativeFolder: entry.fullPath.replace(/\/[^/]*$/, '')
});
resolveFile();
});
});
resolveFile();
});
});
} else {
return FileUtils.flatten(entry).then((result) => {
files.push(...result);
});
}
})));
} else {
return FileUtils.flatten(entry).then((result) => {
files.push(...result);
});
}
})
)
);
// Try calling traverse() again for the same dir, according to spec
traverse();
}