Skip to content

Commit

Permalink
fix: skip download exists binary file (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Feb 2, 2023
1 parent 84eff97 commit f4f40ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/core/service/BinarySyncerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ export class BinarySyncerService extends AbstractService {
} else {
// download to nfs
logs.push(`[${isoNow()}][${dir}] 🚧 [${parentIndex}${index}] Downloading ${JSON.stringify(item)}, reason: ${reason}`);
// skip exists binary file
const existsBinary = await this.binaryRepository.findBinary(item.category, item.parent, item.name);
if (existsBinary && existsBinary.date === item.date) {
logs.push(`[${isoNow()}][${dir}] 🟢 [${parentIndex}${index}] binary file exists, skip download, binaryId: ${existsBinary.binaryId}`);
this.logger.info('[BinarySyncerService.syncDir:skipDownload] binaryId: %s exists, storePath: %s',
existsBinary.binaryId, existsBinary.storePath);
continue;
}
await this.taskService.appendTaskLog(task, logs.join('\n'));
logs = [];
let localFile = '';
Expand Down
4 changes: 3 additions & 1 deletion test/core/service/BinarySyncerService/executeTask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ describe('test/core/service/BinarySyncerService/executeTask.test.ts', () => {
return {
items: [
{ name: 'latest/', isDir: true, url: '', size: '-', date: '17-Dec-2021 23:17' },
{ name: 'index.json', isDir: false, url: 'https://nodejs.org/dist/index.json', size: '219862', date: '18-Dec-2021 23:16' },
{ name: 'index.json', isDir: false, url: 'https://nodejs.org/dist/index.json', size: '219862',
// change date
date: '20-Dec-2021 23:16' },
],
};
}
Expand Down

0 comments on commit f4f40ed

Please sign in to comment.