mirror of
https://github.com/outline/outline.git
synced 2026-12-04 18:34:54 +03:00
fix: move root dir creation under plugin as a util
This commit is contained in:
1 parent
13bd9d55cd
commit
d1c0d506e5
3 files changed
+23
-7
No files matched your search
@@ -23,8 +23,11 @@ import { authorize } from "@server/policies";
|
||||
import { APIContext } from "@server/types";
|
||||
import { getAttachmentForJWT } from "@server/utils/jwt";
|
||||
import { getFileFromRequest } from "@server/utils/koa";
|
||||
import { createRootDirForLocalStorage } from "../utils";
|
||||
import * as T from "./schema";
|
||||
|
||||
createRootDirForLocalStorage();
|
||||
|
||||
const router = new Router();
|
||||
|
||||
router.post(
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { existsSync, mkdirSync } from "fs";
|
||||
import env from "@server/env";
|
||||
import Logger from "@server/logging/Logger";
|
||||
|
||||
export const createRootDirForLocalStorage = () => {
|
||||
if (env.FILE_STORAGE === "local") {
|
||||
const rootDir = env.FILE_STORAGE_LOCAL_ROOT;
|
||||
try {
|
||||
if (!existsSync(rootDir)) {
|
||||
mkdirSync(rootDir);
|
||||
Logger.debug("utils", `Created ${rootDir} for local storage`);
|
||||
}
|
||||
} catch (err) {
|
||||
Logger.fatal(
|
||||
"Couldn't create root dir for local storage of attachments",
|
||||
err
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -26,7 +26,6 @@ import ShutdownHelper, { ShutdownOrder } from "./utils/ShutdownHelper";
|
||||
import { sequelize } from "./storage/database";
|
||||
import RedisAdapter from "./storage/redis";
|
||||
import Metrics from "./logging/Metrics";
|
||||
import { mkdirSync, existsSync } from "fs";
|
||||
|
||||
// The default is to run all services to make development and OSS installations
|
||||
// easier to deal with. Separate services are only needed at scale.
|
||||
@@ -52,12 +51,6 @@ if (serviceNames.includes("collaboration")) {
|
||||
// This function will only be called once in the original process
|
||||
async function master() {
|
||||
await checkEnv();
|
||||
if (env.FILE_STORAGE === "local") {
|
||||
const rootDir = env.FILE_STORAGE_LOCAL_ROOT;
|
||||
if (!existsSync(rootDir)) {
|
||||
mkdirSync(rootDir);
|
||||
}
|
||||
}
|
||||
await checkPendingMigrations();
|
||||
|
||||
if (env.TELEMETRY && env.ENVIRONMENT === "production") {
|
||||
|
||||
Reference in new issue
Block a user