mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Move storage names for filesystem and gridfs to constants
This commit is contained in:
parent
99c37bd521
commit
72b8672e62
2 changed files with 13 additions and 10 deletions
|
|
@ -2,6 +2,9 @@ import fs from 'fs';
|
|||
import { createObjectId } from './grid/createObjectId';
|
||||
import { createInterceptDownload } from './fsHooks/createInterceptDownload';
|
||||
|
||||
export const STORAGE_NAME_FILESYSTEM = "fs";
|
||||
export const STORAGE_NAME_GRIDFS = "gridfs";
|
||||
|
||||
/** Factory for FileStoreStrategy */
|
||||
export default class FileStoreStrategyFactory {
|
||||
|
||||
|
|
@ -28,18 +31,18 @@ export default class FileStoreStrategyFactory {
|
|||
if (!storage) {
|
||||
if (fileObj.meta.source == "import") {
|
||||
// uploaded by import, so it's in GridFS (MongoDB)
|
||||
storage = "gridfs";
|
||||
storage = STORAGE_NAME_GRIDFS;
|
||||
} else {
|
||||
// newly uploaded, so it's at the filesystem
|
||||
storage = "fs";
|
||||
storage = STORAGE_NAME_FILESYSTEM;
|
||||
}
|
||||
}
|
||||
}
|
||||
let ret;
|
||||
if (["fs", "gridfs"].includes(storage)) {
|
||||
if (storage == "fs") {
|
||||
if ([STORAGE_NAME_FILESYSTEM, STORAGE_NAME_GRIDFS].includes(storage)) {
|
||||
if (storage == STORAGE_NAME_FILESYSTEM) {
|
||||
ret = new this.classFileStoreStrategyFilesystem(filesCollection, fileObj, versionName);
|
||||
} else if (storage == "gridfs") {
|
||||
} else if (storage == STORAGE_NAME_GRIDFS) {
|
||||
ret = new this.classFileStoreStrategyGridFs(this.gridFsBucket, filesCollection, fileObj, versionName);
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +188,7 @@ export class FileStoreStrategyGridFs extends FileStoreStrategy {
|
|||
* @return the storage name
|
||||
*/
|
||||
getStorageName() {
|
||||
return "gridfs";
|
||||
return STORAGE_NAME_GRIDFS;
|
||||
}
|
||||
|
||||
/** returns the GridFS Object-Id
|
||||
|
|
@ -255,7 +258,7 @@ export class FileStoreStrategyFilesystem extends FileStoreStrategy {
|
|||
* @return the storage name
|
||||
*/
|
||||
getStorageName() {
|
||||
return "fs";
|
||||
return STORAGE_NAME_FILESYSTEM;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue