mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-02 10:52:22 +00:00
22 lines
821 B
TypeScript
22 lines
821 B
TypeScript
import { fetchApi } from "./api-config"
|
|
|
|
interface UpdateObservation {
|
|
last_check?: string | null
|
|
stale?: boolean
|
|
stale_after_seconds?: number
|
|
}
|
|
|
|
export function isLxcUpdateStale(observation?: UpdateObservation, now = Date.now()): boolean {
|
|
if (!observation || observation.stale === true) return true
|
|
const checked = Date.parse(observation.last_check || "")
|
|
const age = now - checked
|
|
const limit = (observation.stale_after_seconds ?? 172800) * 1000
|
|
return !Number.isFinite(checked) || age < 0 || age >= limit
|
|
}
|
|
|
|
// Called only by the OS section's explicit button. Uses installed package
|
|
// state and existing indexes; fetching this never upgrades or refreshes APT.
|
|
export function checkLxcUpdates<T>(vmid: number): Promise<T> {
|
|
return fetchApi<T>(`/api/vms/${vmid}/updates/check`, { method: "POST" })
|
|
}
|