Automatically remove unused game-file versions
This commit is contained in:
@@ -2,6 +2,7 @@ import { json } from '@sveltejs/kit';
|
||||
import { heartbeat, pendingCreationCancellations } from '$lib/server/hosts/index.js';
|
||||
import { authenticateAgent, hostApiError, objectBody } from '$lib/server/hosts/http.js';
|
||||
import { reconcileHostPreparation } from '$lib/server/hosts/preparation.js';
|
||||
import { reconcileHostLibraryCleanup, cleanupControllerLibraries } from '$lib/server/game-files/index.js';
|
||||
export async function POST({ request }: { request: Request }) {
|
||||
const authenticated = authenticateAgent(request);
|
||||
try {
|
||||
@@ -13,6 +14,8 @@ export async function POST({ request }: { request: Request }) {
|
||||
updateHostLibraryCaches(host.id, inventory.libraryCaches, { snapshot: true });
|
||||
}
|
||||
reconcileHostPreparation(host.id);
|
||||
reconcileHostLibraryCleanup(host.id);
|
||||
await cleanupControllerLibraries();
|
||||
return json({ host, cancelledCreations: pendingCreationCancellations(host.id), heartbeatSeconds: 15, serverTime: new Date().toISOString() });
|
||||
} catch (cause) { return hostApiError(cause); }
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ export function GET({ request, params }: { request: Request; params: { id: strin
|
||||
authenticateAgent(request);
|
||||
const version = getLibraryVersion(params.id);
|
||||
if (!version || version.state !== 'ready') return json({ error: 'Published library not found.' }, { status: 404 });
|
||||
if (version.filesRemoved || version.filesRemoving) return json({ error: 'These outdated game files have been removed.' }, { status: 410 });
|
||||
return json({ id: version.id, game: version.game, files: version.files, sizeBytes: version.sizeBytes, manifestSha256: version.manifestSha256 });
|
||||
} catch (cause) { return gameFileError(cause); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user