2024-11-05 11:12:42 +00:00
|
|
|
"use strict";
|
|
|
|
exports.id = 6715;
|
|
|
|
exports.ids = [6715];
|
|
|
|
exports.modules = {
|
|
|
|
|
|
|
|
/***/ 6715:
|
|
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
|
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
const fs = __webpack_require__(7147);
|
|
|
|
const path = __webpack_require__(1017);
|
|
|
|
/**
|
|
|
|
* Imports: Handle imports
|
|
|
|
*/ /**
|
|
|
|
* Grab Paths Function
|
|
|
|
* ==============================================================================
|
|
|
|
* @description Description
|
|
|
|
*
|
|
|
|
* @param {object} params - An object containing the function parameters.
|
|
|
|
* @param {boolean} [params.isPrivate] - Is this file private or not?
|
|
|
|
* @param {any} params.user - User object
|
|
|
|
* @param {string} [params.folder] - Folder, if available
|
|
|
|
* @param {boolean} [params.video] - Video, if available
|
|
|
|
* @param {boolean} [params.pathOnly] - Just generate the directories' paths
|
|
|
|
*
|
|
|
|
* @returns {{ fileRootPath: string, urlRootPath: string, relativePath: string } | null}
|
|
|
|
*/ module.exports = function grabPaths({ isPrivate , user , folder , video , pathOnly , }) {
|
|
|
|
/**
|
|
|
|
* Initialize variables
|
|
|
|
*/ const isProduction = "production".match(/production/);
|
|
|
|
const userId = user?.id || user?.user_id;
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Handle function logic
|
|
|
|
*/ const STATIC_ROOT = process.env.DSQL_STATIC_SERVER_DIR;
|
|
|
|
if (!STATIC_ROOT) {
|
|
|
|
console.log("Static File ENV not Found!");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
const relativePath = isPrivate ? `@/${video ? "videos" : "media"}/${folder ? folder + "/" : ""}` : video ? `/videos/user-videos/user-${userId}/${folder ? folder + "/" : ""}` : `/images/user-images/user-${userId}/${folder ? folder + "/" : ""}`;
|
2024-11-05 14:18:40 +00:00
|
|
|
const fileRootPath = isPrivate ? `${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${userId}/media/${folder ? folder + "/" : ""}` : path.join(STATIC_ROOT, relativePath);
|
2024-11-05 11:12:42 +00:00
|
|
|
if (!fs.existsSync(fileRootPath) && !pathOnly) {
|
|
|
|
fs.mkdirSync(fileRootPath, {
|
|
|
|
recursive: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
const urlRootPath = isPrivate ? `@/media/${folder ? folder + "/" : ""}` : `${process.env.DSQL_STATIC_HOST}${relativePath}`;
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Return statement
|
|
|
|
*/ return {
|
|
|
|
fileRootPath: fileRootPath,
|
|
|
|
urlRootPath: urlRootPath,
|
|
|
|
relativePath
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
|
|
};
|
|
|
|
;
|