mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-14 16:51:15 +10:00
feat: new unified data folder
This commit is contained in:
@ -2,6 +2,7 @@ import path from "path";
|
||||
import fs from "fs";
|
||||
import type { CertificateBundle } from "./ca";
|
||||
import prisma from "../db/database";
|
||||
import { systemConfig } from "../config/sys-conf";
|
||||
|
||||
export type CertificateStore = {
|
||||
store(name: string, data: CertificateBundle): Promise<void>;
|
||||
@ -10,7 +11,8 @@ export type CertificateStore = {
|
||||
checkBlacklistCertificate(name: string): Promise<boolean>;
|
||||
};
|
||||
|
||||
export const fsCertificateStore = (base: string) => {
|
||||
export const fsCertificateStore = () => {
|
||||
const base = path.join(systemConfig.getDataFolder(), "certs");
|
||||
const blacklist = path.join(base, ".blacklist");
|
||||
fs.mkdirSync(blacklist, { recursive: true });
|
||||
const store: CertificateStore = {
|
||||
|
||||
14
server/internal/config/sys-conf.ts
Normal file
14
server/internal/config/sys-conf.ts
Normal file
@ -0,0 +1,14 @@
|
||||
class SystemConfig {
|
||||
private libraryFolder = process.env.LIBRARY ?? "./.data/library";
|
||||
private dataFolder = process.env.DATA ?? "./.data/data";
|
||||
|
||||
getLibraryFolder() {
|
||||
return this.libraryFolder;
|
||||
}
|
||||
|
||||
getDataFolder() {
|
||||
return this.dataFolder;
|
||||
}
|
||||
}
|
||||
|
||||
export const systemConfig = new SystemConfig();
|
||||
@ -15,12 +15,13 @@ import taskHandler from "../tasks";
|
||||
import { parsePlatform } from "../utils/parseplatform";
|
||||
import droplet from "@drop-oss/droplet";
|
||||
import notificationSystem from "../notifications";
|
||||
import { systemConfig } from "../config/sys-conf";
|
||||
|
||||
class LibraryManager {
|
||||
private basePath: string;
|
||||
|
||||
constructor() {
|
||||
this.basePath = process.env.LIBRARY ?? "./.data/library";
|
||||
this.basePath = systemConfig.getLibraryFolder();
|
||||
fs.mkdirSync(this.basePath, { recursive: true });
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import { Readable } from "stream";
|
||||
import { createHash } from "crypto";
|
||||
import prisma from "../db/database";
|
||||
import cacheHandler from "../cache";
|
||||
import { systemConfig } from "../config/sys-conf";
|
||||
|
||||
export class FsObjectBackend extends ObjectBackend {
|
||||
private baseObjectPath: string;
|
||||
@ -16,7 +17,7 @@ export class FsObjectBackend extends ObjectBackend {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
const basePath = process.env.FS_BACKEND_PATH ?? "./.data/objects";
|
||||
const basePath = path.join(systemConfig.getDataFolder(), "objects");
|
||||
this.baseObjectPath = path.join(basePath, "objects");
|
||||
this.baseMetadataPath = path.join(basePath, "metadata");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user