mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-14 00:31:25 +10:00
Rearchitecture for v0.4.0 (#197)
* feat: database redist support * feat: rearchitecture of database schemas, migration reset, and #180 * feat: import redists * fix: giantbomb logging bug * feat: partial user platform support + statusMessage -> message * feat: add user platform filters to store view * fix: sanitize svg uploads ... copilot suggested this I feel dirty. * feat: beginnings of platform & redist management * feat: add server side redist patching * fix: update drop-base commit * feat: import of custom platforms & file extensions * fix: redelete platform * fix: remove platform * feat: uninstall commands, new R UI * checkpoint: before migrating to nuxt v4 * update to nuxt 4 * fix: fixes for Nuxt v4 update * fix: remaining type issues * feat: initial feedback to import other kinds of versions * working commit * fix: lint * feat: redist import
This commit is contained in:
@ -1,18 +1,27 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import type { EventHandlerRequest, H3Event } from "h3";
|
||||
import type { Dump, Pull } from "../objects/transactional";
|
||||
import type { Dump, Pull, Register } from "../objects/transactional";
|
||||
import { ObjectTransactionalHandler } from "../objects/transactional";
|
||||
|
||||
type RecursiveType =
|
||||
| { [key: string]: RecursiveType }
|
||||
| string
|
||||
| number
|
||||
| Array<RecursiveType>;
|
||||
|
||||
export async function handleFileUpload(
|
||||
h3: H3Event<EventHandlerRequest>,
|
||||
metadata: { [key: string]: string },
|
||||
permissions: Array<string>,
|
||||
max = -1,
|
||||
): Promise<[string[], { [key: string]: string }, Pull, Dump] | undefined> {
|
||||
): Promise<
|
||||
[string[], { [key: string]: RecursiveType }, Pull, Dump, Register] | undefined
|
||||
> {
|
||||
const formData = await readMultipartFormData(h3);
|
||||
if (!formData) return undefined;
|
||||
const transactionalHandler = new ObjectTransactionalHandler();
|
||||
const [add, pull, dump] = transactionalHandler.new(metadata, permissions);
|
||||
const options: { [key: string]: string } = {};
|
||||
const options: any = {};
|
||||
const ids = [];
|
||||
|
||||
for (const entry of formData) {
|
||||
@ -25,8 +34,15 @@ export async function handleFileUpload(
|
||||
}
|
||||
if (!entry.name) continue;
|
||||
|
||||
options[entry.name] = entry.data.toString("utf-8");
|
||||
const path = entry.name.split(".");
|
||||
let v = options;
|
||||
for (const pathPart of path.slice(0, -1)) {
|
||||
(v as any)[pathPart] ??= {};
|
||||
v = (v as any)[pathPart];
|
||||
}
|
||||
|
||||
(v as any)[path.at(-1)!] = entry.data.toString("utf-8");
|
||||
}
|
||||
|
||||
return [ids, options, pull, dump];
|
||||
return [ids, options, pull, dump, add];
|
||||
}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { Platform } from "~/prisma/client/enums";
|
||||
import { HardwarePlatform } from "~~/prisma/client/enums";
|
||||
|
||||
export function parsePlatform(platform: string) {
|
||||
switch (platform.toLowerCase()) {
|
||||
case "linux":
|
||||
return Platform.Linux;
|
||||
return HardwarePlatform.Linux;
|
||||
case "windows":
|
||||
return Platform.Windows;
|
||||
return HardwarePlatform.Windows;
|
||||
case "mac":
|
||||
case "macos":
|
||||
return Platform.macOS;
|
||||
return HardwarePlatform.macOS;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
||||
@ -80,11 +80,12 @@ export class PriorityListIndexed<T> extends PriorityList<T> {
|
||||
|
||||
override pop(position?: number): PriorityTagged<T> {
|
||||
const value = super.pop(position);
|
||||
if(!value) return undefined!;
|
||||
|
||||
const index = this.getIndex(value.object);
|
||||
this.indexMap.delete(index);
|
||||
|
||||
return value;
|
||||
return value!;
|
||||
}
|
||||
|
||||
get(index: string) {
|
||||
|
||||
Reference in New Issue
Block a user