game version re-ordering

This commit is contained in:
DecDuck
2024-10-14 20:34:23 +11:00
parent 8674ac7211
commit 329c74d3ce
18 changed files with 354 additions and 50 deletions

View File

@ -1,8 +1,16 @@
# Drop Download System
Drop downloads come in two types:
# Drop P2P System
Drop clients have a variety of P2P or P2P-like methods of data transfer available
## Public (not quite) HTTPS downloads endpoints
These use public HTTPS certificate, and while are authenticated, are 'public' in the sense that they aren't P2P; anyone can connect to them
## Private mTLS P2P endpoints
Drop clients use P2P mTLS aided by the P2P co-ordinator to transfer chunks between themselves.
Drop clients use P2P mTLS aided by the P2P co-ordinator to transfer chunks between themselves. This happens over HTTP.
## Private mTLS Wireguard tunnels
Drop clients can establish P2P Wireguard

View File

@ -0,0 +1,52 @@
export type DropChunk = {
permissions: number;
ids: string[];
checksums: string[];
lengths: string[];
};
export type DropManifest = {
[key: string]: DropChunk;
};
export type DropManifestMetadata = {
manifest: DropManifest;
versionName: string;
};
export type DropGeneratedManifest = DropManifest & {
[key: string]: { versionName: string };
};
class ManifestGenerator {
static generateManifest(
rootManifest: DropManifestMetadata,
...overlays: DropManifestMetadata[]
): DropGeneratedManifest {
if (overlays.length == 0) {
return Object.fromEntries(
Object.entries(rootManifest.manifest).map(([key, value]) => [
key,
Object.assign({}, value, { versionName: rootManifest.versionName }),
])
);
}
// Recurse in verse order through versions, skipping files that already exist.
const versions = [...overlays.reverse(), rootManifest];
const manifest: DropGeneratedManifest = {};
for (const version of versions) {
for (const [filename, chunk] of Object.entries(version.manifest)) {
if (manifest[filename]) continue;
manifest[filename] = Object.assign({}, chunk, {
versionName: version.versionName,
});
}
}
return manifest;
}
}
export const manifestGenerator = new ManifestGenerator();
export default manifestGenerator;

View File

@ -195,7 +195,8 @@ class LibraryManager {
async importVersion(
gameId: string,
versionName: string,
metadata: { platform: string; setup: string; startup: string }
metadata: { platform: string; setup: string; startup: string },
delta = false
) {
const taskId = `import:${gameId}:${versionName}`;
@ -238,6 +239,10 @@ class LibraryManager {
log("Created manifest successfully!");
const currentIndex = await prisma.gameVersion.count({
where: { gameId: gameId },
});
// Then, create the database object
const version = await prisma.gameVersion.create({
data: {
@ -247,6 +252,8 @@ class LibraryManager {
setupCommand: metadata.setup,
launchCommand: metadata.startup,
dropletManifest: manifest,
versionIndex: currentIndex,
delta: delta,
},
});