Skip to content

Commit c17ae72

Browse files
committed
chore: extract freshnessMs as VERSION_CACHE_TTL_MS
1 parent b39eb44 commit c17ae72

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/versions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ export class BaseVersions implements Versions {
183183
}
184184
}
185185

186+
const VERSION_CACHE_TTL_MS = 4 * 60 * 60 * 1000; // cache for N hours
187+
186188
/**
187189
* Implementation of Versions that self-populates from release information at
188190
* https://releases.electronjs.org/releases.json .
189191
*
190192
* This is generally what to use in production.
191193
*/
192194
export class ElectronVersions extends BaseVersions {
193-
private static readonly freshnessMs = 4 * 60 * 60 * 1000; // cache for N hours
194-
195195
private constructor(
196196
private readonly versionsCache: string,
197197
private mtimeMs: number,
@@ -220,7 +220,7 @@ export class ElectronVersions extends BaseVersions {
220220
const now = Date.now();
221221
try {
222222
const st = await fs.stat(versionsCache);
223-
if (now <= st.mtimeMs + ElectronVersions.freshnessMs)
223+
if (now <= st.mtimeMs + VERSION_CACHE_TTL_MS)
224224
versions = (await fs.readJson(versionsCache)) as unknown;
225225
} catch (err) {
226226
// cache file missing
@@ -244,7 +244,7 @@ export class ElectronVersions extends BaseVersions {
244244
// if it's still fresh, do nothing
245245
const { mtimeMs, versionsCache } = this;
246246
const now = Date.now();
247-
if (now <= mtimeMs + ElectronVersions.freshnessMs) return;
247+
if (now <= mtimeMs + VERSION_CACHE_TTL_MS) return;
248248

249249
// update the cache
250250
try {

0 commit comments

Comments
 (0)