Skip to content

Commit e46d017

Browse files
committed
fix patchfromppk
1 parent 366b2a6 commit e46d017

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

harmony/pushy/src/main/ets/DownloadTask.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -262,37 +262,44 @@ export class DownloadTask {
262262

263263
let foundDiff = false;
264264
let foundBundlePatch = false;
265-
const copyList: Map<string, Array<any>> = new Map();
266265
await zlib.decompressFile(params.targetFile, params.unzipDirectory);
267266
const zipFile = await this.processUnzippedFiles(params.unzipDirectory);
268267
for (const entry of zipFile.entries) {
269268
const fn = entry.filename;
270269

271270
if (fn === '__diff.json') {
272271
foundDiff = true;
272+
273+
await fileIo
274+
.copyDir(params.originDirectory + '/', params.unzipDirectory + '/')
275+
.catch(error => {
276+
console.error('copy error:', error);
277+
});
278+
273279
let jsonContent = '';
274280
const bufferArray = new Uint8Array(entry.content);
275281
for (let i = 0; i < bufferArray.length; i++) {
276282
jsonContent += String.fromCharCode(bufferArray[i]);
277283
}
278284
const obj = JSON.parse(jsonContent);
279285

280-
const copies = obj.copies;
281-
for (const to in copies) {
282-
let from = copies[to];
283-
if (from === '') {
284-
from = to;
285-
}
286-
287-
if (!copyList.has(from)) {
288-
copyList.set(from, []);
289-
}
290-
291-
const target = copyList.get(from);
292-
if (target) {
293-
const toFile = `${params.unzipDirectory}/${to}`;
294-
target.push(toFile);
295-
}
286+
const { copies, deletes } = obj;
287+
for (const [to, from] of Object.entries(copies)) {
288+
await fileIo
289+
.copyFile(
290+
`${params.originDirectory}/${from}`,
291+
`${params.unzipDirectory}/${to}`,
292+
)
293+
.catch(error => {
294+
console.error('copy error:', error);
295+
});
296+
}
297+
for (const fileToDelete of Object.keys(deletes)) {
298+
await fileIo
299+
.unlink(`${params.unzipDirectory}/${fileToDelete}`)
300+
.catch(error => {
301+
console.error('delete error:', error);
302+
});
296303
}
297304
continue;
298305
}

0 commit comments

Comments
 (0)