diff --git a/lib/external-resources/resource.js b/lib/external-resources/resource.js index 4b5d8dd..c61f70b 100644 --- a/lib/external-resources/resource.js +++ b/lib/external-resources/resource.js @@ -4,6 +4,8 @@ import path from "node:path"; import stream from "node:stream"; import tar from "#lib/tar"; +const DEFAULT_CHECK_TIMEOUT = 1000 * 60 * 60; // 1 hour + export default class ExternalResource extends Events { #id; #location; @@ -68,6 +70,14 @@ export default class ExternalResource extends Events { return this.#index?.meta; } + get lastChecked () { + return this.#index.lastChecked; + } + + get lastUpdated () { + return this.#index.lastUpdated; + } + // public async check ( { remote = false, forceRemote } = {} ) { const res = await this.update( { @@ -97,6 +107,9 @@ export default class ExternalResource extends Events { // resource is expired if ( this.isExpired ) remote = true; + // last checked interval + if ( this.lastChecked && this.lastChecked + DEFAULT_CHECK_TIMEOUT < Date.now() ) remote = true; + // resource exists if ( isInstalled && !remote ) return result( 304 );