In-app store, torrential backend, locales (#332)
* feat: add store nav and fixes * fix: reduce password requirement & new task error ui * fix: client webtoken fix * fix: delta versions and dockerfile * fix: use setup platforms for filter & display * fix: setup not accounted when returning valid options * feat: tighter delta version support * feat: dl/disk size * feat: offload manifest generation to torrential * fix: bump torrential * feat: remove droplet * feat: bump torrential * feat: convert locales
This commit is contained in:
@@ -7,13 +7,8 @@ import {
|
||||
import { LibraryBackend } from "~/prisma/client/enums";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import droplet, {
|
||||
hasBackendForPath,
|
||||
listFiles,
|
||||
peekFile,
|
||||
readFile,
|
||||
} from "@drop-oss/droplet";
|
||||
import { fsStats } from "~/server/internal/utils/files";
|
||||
import { dropletInterface } from "../../services/torrential/droplet-interface";
|
||||
|
||||
export const FilesystemProviderConfig = type({
|
||||
baseDir: "string",
|
||||
@@ -64,57 +59,49 @@ export class FilesystemProvider
|
||||
const gameDir = path.join(this.config.baseDir, game);
|
||||
if (!fs.existsSync(gameDir)) throw new GameNotFoundError();
|
||||
const versionDirs = fs.readdirSync(gameDir);
|
||||
const validVersionDirs = versionDirs.filter((e) => {
|
||||
if (ignoredVersions && ignoredVersions.includes(e)) return false;
|
||||
const fullDir = path.join(this.config.baseDir, game, e);
|
||||
return hasBackendForPath(fullDir);
|
||||
});
|
||||
const validVersionDirs = [];
|
||||
|
||||
for (const versionDir of versionDirs) {
|
||||
if (ignoredVersions && ignoredVersions.includes(versionDir)) continue;
|
||||
const fullDir = path.join(this.config.baseDir, game, versionDir);
|
||||
const valid = await dropletInterface.hasBackend(fullDir);
|
||||
if (!valid) continue;
|
||||
|
||||
validVersionDirs.push(versionDir);
|
||||
}
|
||||
|
||||
return validVersionDirs;
|
||||
}
|
||||
|
||||
async versionReaddir(game: string, version: string): Promise<string[]> {
|
||||
const versionDir = path.join(this.config.baseDir, game, version);
|
||||
if (!fs.existsSync(versionDir)) throw new VersionNotFoundError();
|
||||
return await listFiles(versionDir);
|
||||
return await dropletInterface.listFiles(versionDir);
|
||||
}
|
||||
|
||||
async generateDropletManifest(
|
||||
game: string,
|
||||
version: string,
|
||||
progress: (err: Error | null, v: number) => void,
|
||||
log: (err: Error | null, v: string) => void,
|
||||
progress: (v: number) => void,
|
||||
log: (v: string) => void,
|
||||
): Promise<string> {
|
||||
const versionDir = path.join(this.config.baseDir, game, version);
|
||||
if (!fs.existsSync(versionDir)) throw new VersionNotFoundError();
|
||||
const manifest = await droplet.generateManifest(versionDir, progress, log);
|
||||
const manifest = await dropletInterface.generateDropletManifest(
|
||||
versionDir,
|
||||
progress,
|
||||
log,
|
||||
);
|
||||
return manifest;
|
||||
}
|
||||
|
||||
async peekFile(game: string, version: string, filename: string) {
|
||||
const filepath = path.join(this.config.baseDir, game, version);
|
||||
if (!fs.existsSync(filepath)) return undefined;
|
||||
const stat = await peekFile(filepath, filename);
|
||||
const stat = await dropletInterface.peekFile(filepath, filename);
|
||||
return { size: Number(stat) };
|
||||
}
|
||||
|
||||
async readFile(
|
||||
game: string,
|
||||
version: string,
|
||||
filename: string,
|
||||
options?: { start?: number; end?: number },
|
||||
) {
|
||||
const filepath = path.join(this.config.baseDir, game, version);
|
||||
if (!fs.existsSync(filepath)) return undefined;
|
||||
const stream = await readFile(
|
||||
filepath,
|
||||
filename,
|
||||
options?.start ? BigInt(options.start) : undefined,
|
||||
options?.end ? BigInt(options.end) : undefined,
|
||||
);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
fsStats() {
|
||||
return fsStats(this.config.baseDir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user