Skip to content

Commit 1e29aab

Browse files
committed
skip non rawfile resource
1 parent 523f2c6 commit 1e29aab

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,13 @@ export class DownloadTask {
193193
}
194194
const obj = JSON.parse(jsonContent);
195195

196-
const copies = obj.copies;
197-
for (const to in copies) {
198-
let from = copies[to].replace('resources/rawfile/', '');
196+
const copies = obj.copies as Record<string, string>;
197+
for (const [to, rawPath] of Object.entries(copies)) {
198+
if (!rawPath.startsWith('resources/rawfile/')) {
199+
// skip other resource
200+
continue;
201+
}
202+
let from = rawPath.replace('resources/rawfile/', '');
199203
if (from === '') {
200204
from = to;
201205
}
@@ -355,10 +359,12 @@ export class DownloadTask {
355359
private async copyFromResource(
356360
copyList: Map<string, Array<string>>,
357361
): Promise<void> {
362+
let currentFrom = '';
358363
try {
359364
const resourceManager = this.context.resourceManager;
360365

361366
for (const [from, targets] of copyList.entries()) {
367+
currentFrom = from;
362368
const fromContent = await resourceManager.getRawFileContent(from);
363369
for (const target of targets) {
364370
const fileStream = fileIo.createStreamSync(target, 'w+');
@@ -367,7 +373,7 @@ export class DownloadTask {
367373
}
368374
}
369375
} catch (error) {
370-
console.error('Copy from resource failed:', error);
376+
console.error('Copy from resource failed:', currentFrom, error.message);
371377
throw error;
372378
}
373379
}
@@ -429,7 +435,7 @@ export class DownloadTask {
429435

430436
params.listener?.onDownloadCompleted(params);
431437
} catch (error) {
432-
console.error('Task execution failed:', error);
438+
console.error('Task execution failed:', error.message);
433439
if (params.type !== DownloadTaskParams.TASK_TYPE_CLEANUP) {
434440
try {
435441
if (params.type === DownloadTaskParams.TASK_TYPE_PLAIN_DOWNLOAD) {
@@ -438,7 +444,7 @@ export class DownloadTask {
438444
await this.removeDirectory(params.unzipDirectory);
439445
}
440446
} catch (cleanupError) {
441-
console.error('Cleanup after error failed:', cleanupError);
447+
console.error('Cleanup after error failed:', cleanupError.message);
442448
}
443449
}
444450
params.listener?.onDownloadFailed(error);

0 commit comments

Comments
 (0)