mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-14 16:51:15 +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,13 +1,11 @@
|
||||
import { LibraryBackend } from "~/prisma/client/enums";
|
||||
import type { LibraryBackend } from "~~/prisma/client/enums";
|
||||
import prisma from "../internal/db/database";
|
||||
import type { JsonValue } from "@prisma/client/runtime/library";
|
||||
import type { LibraryProvider } from "../internal/library/provider";
|
||||
import type { FilesystemProviderConfig } from "../internal/library/providers/filesystem";
|
||||
import { FilesystemProvider } from "../internal/library/providers/filesystem";
|
||||
import libraryManager from "../internal/library";
|
||||
import path from "path";
|
||||
import { FlatFilesystemProvider } from "../internal/library/providers/flat";
|
||||
import { logger } from "~/server/internal/logging";
|
||||
import { logger } from "~~/server/internal/logging";
|
||||
|
||||
export const libraryConstructors: {
|
||||
[key in LibraryBackend]: (
|
||||
@ -33,42 +31,6 @@ export default defineNitroPlugin(async () => {
|
||||
let successes = 0;
|
||||
const libraries = await prisma.library.findMany({});
|
||||
|
||||
// Add migration handler
|
||||
const legacyPath = process.env.LIBRARY;
|
||||
if (legacyPath && libraries.length == 0) {
|
||||
const options: typeof FilesystemProviderConfig.infer = {
|
||||
baseDir: path.resolve(legacyPath),
|
||||
};
|
||||
|
||||
const library = await prisma.library.create({
|
||||
data: {
|
||||
name: "Auto-created",
|
||||
backend: LibraryBackend.Filesystem,
|
||||
options,
|
||||
},
|
||||
});
|
||||
|
||||
libraries.push(library);
|
||||
|
||||
// Update all existing games
|
||||
await prisma.game.updateMany({
|
||||
where: {
|
||||
libraryId: null,
|
||||
},
|
||||
data: {
|
||||
libraryId: library.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Delete all games that don't have a library provider after the legacy handler
|
||||
// (leftover from a bug)
|
||||
await prisma.game.deleteMany({
|
||||
where: {
|
||||
libraryId: null,
|
||||
},
|
||||
});
|
||||
|
||||
for (const library of libraries) {
|
||||
const constructor = libraryConstructors[library.backend];
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user