ソースを参照

Revert "use tempdirs"

This reverts commit a7d51cf21b663d87f83e2585502ed9323b3d3788.
David Arnold 4 年 前
コミット
1cddd607ec
3 ファイル変更12 行追加20 行削除
  1. 0 3
      models/attachments.js
  2. 0 3
      models/avatars.js
  3. 12 14
      server/migrations.js

+ 0 - 3
models/attachments.js

@@ -5,8 +5,6 @@ import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
 import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
 import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
 
-const os = require('os');
-
 let attachmentBucket;
 if (Meteor.isServer) {
   attachmentBucket = createBucket('attachments');
@@ -33,7 +31,6 @@ const insertActivity = (fileObj, activityType) =>
 Attachments = new FilesCollection({
   debug: false, // Change to `true` for debugging
   collectionName: 'attachments',
-  storagePath: os.tmpdir(),
   allowClientCode: true,
   onAfterUpload: function onAfterUpload(fileRef) {
     createOnAfterUpload(attachmentBucket).call(this, fileRef);

+ 0 - 3
models/avatars.js

@@ -5,8 +5,6 @@ import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
 import { createInterceptDownload } from './lib/fsHooks/createInterceptDownload';
 import { createOnAfterRemove } from './lib/fsHooks/createOnAfterRemove';
 
-const os = require('os');
-
 let avatarsBucket;
 if (Meteor.isServer) {
   avatarsBucket = createBucket('avatars');
@@ -15,7 +13,6 @@ if (Meteor.isServer) {
 Avatars = new FilesCollection({
   debug: false, // Change to `true` for debugging
   collectionName: 'avatars',
-  storagePath: os.tmpdir(),
   allowClientCode: true,
   onBeforeUpload(file) {
     if (file.size <= 72000 && file.type.startsWith('image/')) {

+ 12 - 14
server/migrations.js

@@ -23,6 +23,9 @@ import Swimlanes from '../models/swimlanes';
 import Triggers from '../models/triggers';
 import UnsavedEdits from '../models/unsavedEdits';
 import Users from '../models/users';
+
+const fs = require('fs');
+
 // Anytime you change the schema of one of the collection in a non-backward
 // compatible way you have to write a migration in this file using the following
 // API:
@@ -1128,17 +1131,14 @@ Migrations.add('add-card-details-show-lists', () => {
 });
 
 Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
-  const os = require('os');
-  const fs = require('fs');
-  const path = require('path');
-  tmdir = os.tmpdir();
-
   AttachmentsOld.find().forEach(function(fileObj) {
     //console.log('File: ', fileObj.userId);
 
     // This directory must be writable on server, so a test run first
-    // We are going to copy the files locally, then move them to mongo bucket
-    const fileName = path.join(tmpdir, `${fileObj._id}-${fileObj.name()}`);
+    // We are going to copy the files locally, then move them to S3
+    const fileName = `./assets/app/uploads/attachments/${
+      fileObj._id
+    }-${fileObj.name()}`;
     const newFileName = fileObj.name();
 
     // This is "example" variable, change it to the userId that you might be using.
@@ -1196,18 +1196,16 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
     readStream.pipe(writeStream);
   });
 });
-Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
-  const os = require('os');
-  const fs = require('fs');
-  const path = require('path');
-  tmdir = os.tmpdir();
 
+Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
   AvatarsOld.find().forEach(function(fileObj) {
     //console.log('File: ', fileObj.userId);
 
     // This directory must be writable on server, so a test run first
-    // We are going to copy the files locally, then move them to mongo bucket
-    const fileName = path.join(tmpdir, `${fileObj._id}-${fileObj.name()}`);
+    // We are going to copy the files locally, then move them to S3
+    const fileName = `./assets/app/uploads/avatars/${
+      fileObj._id
+    }-${fileObj.name()}`;
     const newFileName = fileObj.name();
 
     // This is "example" variable, change it to the userId that you might be using.