mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-12 15:52:39 +10:00
game version re-ordering
This commit is contained in:
@ -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
|
||||
52
server/internal/downloads/manifest.ts
Normal file
52
server/internal/downloads/manifest.ts
Normal 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;
|
||||
@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user