Skip to content

Commit b7b736b

Browse files
authored
[Fix] Caching in downloadFile (#3484)
* Properly cache files downloaded with `downloadFile` * Bump up the max cache time to 30 days Somewhat of a band-aid fix; ideally we'd be smarter about this caching in the first place (for example only re-downloading if the user's hardware changed)
1 parent b261772 commit b7b736b

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/backend/utils/inet/downloader/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ async function downloadFile(
5151
if (options.maxCache && options.writeToFile) {
5252
const stats = await stat(options.writeToFile).catch(() => null)
5353
if (stats) {
54-
if (stats.birthtime.valueOf() + options.maxCache * 1000 >= Date.now()) {
55-
console.log('Returning cached value for', url)
54+
if (stats.mtimeMs + options.maxCache * 1000 >= Date.now()) {
5655
switch (options.axiosConfig?.responseType) {
5756
case 'text':
5857
return readFile(options.writeToFile, 'utf-8')

src/backend/utils/systeminfo/gpu/pci_ids.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function getPicIds(): Promise<typeof pciIdsMap | null> {
3333
responseType: 'text'
3434
},
3535
writeToFile: path.join(toolsPath, 'pci.ids'),
36-
maxCache: 7 * DAYS
36+
maxCache: 30 * DAYS
3737
}).catch((error) => error as AxiosError)
3838
if (axios.isAxiosError(pciIdsFile)) return null
3939

0 commit comments

Comments
 (0)