Skip to content

Commit

Permalink
Same improvements for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Oct 21, 2023
1 parent e772eff commit 79755fc
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions src/projector/otto/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,37 @@ export class ProjectorOttoWindows extends ProjectorOtto {
* @param dest Output path.
*/
const extract = async (entry: Entry, dest: string) => {
let data: Uint8Array | null = null;
for (const patch of patches) {
if (
entry.type === PathType.FILE &&
patch.match(entry.volumePath)
) {
// eslint-disable-next-line no-await-in-loop
data = data || (await entry.read());
if (!data) {
throw new Error(`Failed to read: ${entry.volumePath}`);
if (entry.type === PathType.FILE) {
let data: Uint8Array | null = null;
for (const patch of patches) {
if (patch.match(entry.volumePath)) {
if (!data) {
// eslint-disable-next-line no-await-in-loop
const d = await entry.read();
if (!d) {
throw new Error(
`Failed to read: ${entry.volumePath}`
);
}
data = new Uint8Array(
d.buffer,
d.byteOffset,
d.byteLength
);
}
// eslint-disable-next-line no-await-in-loop
data = await patch.modify(data);
}
// eslint-disable-next-line no-await-in-loop
data = await patch.modify(data);
}
}

if (data) {
await mkdir(dirname(dest), {recursive: true});
await writeFile(dest, data);
return;
if (data) {
await mkdir(dirname(dest), {recursive: true});
await writeFile(dest, data);
await entry.setAttributes(dest, null, {
ignoreTimes: true
});
return;
}
}

await entry.extract(dest);
Expand Down

0 comments on commit 79755fc

Please sign in to comment.