mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-25 01:13:39 +10:00
game version re-ordering
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
# Drop Download System
|
||||
Drop downloads come in two types:
|
||||
|
||||
## 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.
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user