Browse Source

WRITABLE_PATH is mandatory, so simplify the code logic

Martin Filser 3 years ago
parent
commit
927f155078
3 changed files with 6 additions and 12 deletions
  1. 2 4
      models/attachments.js
  2. 2 4
      models/avatars.js
  3. 2 4
      server/migrations.js

+ 2 - 4
models/attachments.js

@@ -28,10 +28,8 @@ Attachments = new FilesCollection({
     return ret;
   },
   storagePath() {
-    if (process.env.WRITABLE_PATH) {
-      return path.join(process.env.WRITABLE_PATH, 'uploads', 'attachments');
-    }
-    return path.normalize(`assets/app/uploads/${this.collectionName}`);
+    const ret = path.join(process.env.WRITABLE_PATH, 'attachments');
+    return ret;
   },
   onAfterUpload(fileObj) {
     Object.keys(fileObj.versions).forEach(versionName => {

+ 2 - 4
models/avatars.js

@@ -17,10 +17,8 @@ Avatars = new FilesCollection({
   collectionName: 'avatars',
   allowClientCode: true,
   storagePath() {
-    if (process.env.WRITABLE_PATH) {
-      return path.join(process.env.WRITABLE_PATH, 'uploads', 'avatars');
-    }
-    return path.normalize(`assets/app/uploads/${this.collectionName}`);;
+    const ret = path.join(process.env.WRITABLE_PATH, 'avatars');
+    return ret;
   },
   onBeforeUpload(file) {
     if (file.size <= 72000 && file.type.startsWith('image/')) {

+ 2 - 4
server/migrations.js

@@ -1178,8 +1178,7 @@ Migrations.add('add-card-details-show-lists', () => {
 });
 
 Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
-  //const storagePath = Attachments.storagePath();
-  const storagePath = process.env.WRITABLE_PATH || `./wekan-uploads`;
+  const storagePath = Attachments.storagePath();
   if (!fs.existsSync(storagePath)) {
     console.log("create storagePath because it doesn't exist: " + storagePath);
     fs.mkdirSync(storagePath, { recursive: true });
@@ -1246,8 +1245,7 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
 });
 
 Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
-  //const storagePath = Avatars.storagePath();
-  const storagePath = process.env.WRITABLE_PATH || `./wekan-uploads`;
+  const storagePath = Avatars.storagePath();
   if (!fs.existsSync(storagePath)) {
     console.log("create storagePath because it doesn't exist: " + storagePath);
     fs.mkdirSync(storagePath, { recursive: true });