Skip to content

Commit dd4306d

Browse files
authored
fix: sync cache populating (#418)
1 parent c360d39 commit dd4306d

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

backend/src/useCases/objects/object.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -315,20 +315,19 @@ const getNonArchivedObjects = async () => {
315315
}
316316

317317
const populateCaches = async (cid: string) => {
318-
downloadService
319-
.download(cid)
320-
.then((stream) => {
321-
logger.debug(
322-
`Downloaded object (cid=${cid}) from DB after archival check`,
323-
)
324-
consumeStream(stream)
325-
})
326-
.catch((e) => {
327-
logger.warn(
328-
`Failed to download object (cid=${cid}) from DB after archival check: ${e}`,
329-
)
330-
throw e
331-
})
318+
try {
319+
const stream = await downloadService.download(cid)
320+
321+
logger.debug(`Downloaded object (cid=${cid}) from DB after archival check`)
322+
323+
// Wait until the entire stream has been consumed (and therefore cached)
324+
await consumeStream(stream)
325+
} catch (e) {
326+
logger.warn(
327+
`Failed to download object (cid=${cid}) from DB after archival check: ${e}`,
328+
)
329+
throw e
330+
}
332331
}
333332

334333
const onObjectArchived = async (cid: string) => {

0 commit comments

Comments
 (0)