Skip to content

Commit a8b391f

Browse files
committed
Moved hash store check
1 parent ee8c69a commit a8b391f

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/controller/ReportBackendStorageController.ts

+15-11
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,47 @@ export default class ReportBackendStorageController implements Disposable {
3838
const batchSize = 99
3939
for (let i = 0; i < projectReportPaths.length; i += batchSize) {
4040
const batchFiles = projectReportPaths.slice(i, i + batchSize)
41-
const hashes = await Promise.all(batchFiles.map(async (filePath) => {
41+
const hashes = (await Promise.all(batchFiles.map(async (filePath) => {
4242
const unifiedFilePath = new UnifiedPath(filePath)
4343
const reportPath = WorkspaceUtils.getWorkspaceDir()?.join(unifiedFilePath)
4444
if (!reportPath) {
45-
return undefined
45+
return
4646
}
4747

4848
let projectReport
4949
try {
5050
projectReport = ProjectReport.loadFromFile(reportPath, 'bin')
5151
} catch (e) {
52-
return undefined
52+
return
53+
}
54+
const hash = ProjectReport.hashFromBinFile(reportPath)
55+
if (this.isHashChecked(hash, url)) {
56+
return
5357
}
54-
5558
const shouldBeStored = await projectReport?.shouldBeStoredInRegistry()
5659
if (projectReport === undefined || !shouldBeStored) {
57-
return undefined
60+
return
5861
}
5962

60-
return ProjectReport.hashFromBinFile(reportPath)
63+
return hash
6164

62-
}))
65+
}))).filter(hash => hash !== undefined)
6366

64-
const uncheckedHashes = hashes.filter(hash => !this.isHashChecked(hash, url))
65-
if (uncheckedHashes.length === 0) {
67+
if (hashes.length === 0) {
6668
continue
6769
}
6870

69-
const urlWithHashes = `http:/${url}/check-existence?` + uncheckedHashes.map(hash => `hashes[]=${hash}`).join('&')
71+
72+
const urlWithHashes = `http:/${url}/check-existence?` + hashes.map(hash => `hashes[]=${hash}`).join('&')
73+
console.log(urlWithHashes)
7074
const response = await fetch(urlWithHashes)
7175
if (!response.ok) {
7276
console.debug('check-existence Failed!', response.status)
7377
continue
7478
}
7579

7680
const data = await response.json()
77-
for (const hash of uncheckedHashes) {
81+
for (const hash of hashes) {
7882
if (hash && !data[hash]) {
7983
const filePath = batchFiles[hashes.indexOf(hash)]
8084
const unifiedFilePath = new UnifiedPath(filePath)

0 commit comments

Comments
 (0)