mirror of
https://github.com/wekan/wekan.git
synced 2025-12-19 17:00:13 +01:00
Ensure to create the upload directory
This commit is contained in:
parent
086cb9c067
commit
368fe24956
3 changed files with 26 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { FilesCollection } from 'meteor/ostrio:files';
|
import { FilesCollection } from 'meteor/ostrio:files';
|
||||||
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { createBucket } from './lib/grid/createBucket';
|
import { createBucket } from './lib/grid/createBucket';
|
||||||
import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
|
import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
|
||||||
|
|
@ -83,6 +84,12 @@ if (Meteor.isServer) {
|
||||||
|
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
Attachments.collection._ensureIndex({ cardId: 1 });
|
Attachments.collection._ensureIndex({ cardId: 1 });
|
||||||
|
const storagePath = Attachments.storagePath();
|
||||||
|
console.log("Meteor.startup check storagePath: ", storagePath);
|
||||||
|
if (!fs.existsSync(storagePath)) {
|
||||||
|
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { FilesCollection } from 'meteor/ostrio:files';
|
import { FilesCollection } from 'meteor/ostrio:files';
|
||||||
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { createBucket } from './lib/grid/createBucket';
|
import { createBucket } from './lib/grid/createBucket';
|
||||||
import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
|
import { createOnAfterUpload } from './lib/fsHooks/createOnAfterUpload';
|
||||||
|
|
@ -43,6 +44,14 @@ if (Meteor.isServer) {
|
||||||
remove: isOwner,
|
remove: isOwner,
|
||||||
fetch: ['userId'],
|
fetch: ['userId'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Meteor.startup(() => {
|
||||||
|
const storagePath = Avatars.storagePath();
|
||||||
|
if (!fs.existsSync(storagePath)) {
|
||||||
|
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Avatars;
|
export default Avatars;
|
||||||
|
|
|
||||||
|
|
@ -1127,9 +1127,13 @@ Migrations.add('add-card-details-show-lists', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
||||||
|
const storagePath = Attachments.storagePath();
|
||||||
|
if (!fs.existsSync(storagePath)) {
|
||||||
|
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
}
|
||||||
AttachmentsOld.find().forEach(function(fileObj) {
|
AttachmentsOld.find().forEach(function(fileObj) {
|
||||||
const newFileName = fileObj.name();
|
const newFileName = fileObj.name();
|
||||||
const storagePath = Attachments.storagePath({});
|
|
||||||
const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
||||||
|
|
||||||
// This is "example" variable, change it to the userId that you might be using.
|
// This is "example" variable, change it to the userId that you might be using.
|
||||||
|
|
@ -1190,9 +1194,13 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
|
Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
|
||||||
|
const storagePath = Avatars.storagePath();
|
||||||
|
if (!fs.existsSync(storagePath)) {
|
||||||
|
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||||
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
}
|
||||||
AvatarsOld.find().forEach(function(fileObj) {
|
AvatarsOld.find().forEach(function(fileObj) {
|
||||||
const newFileName = fileObj.name();
|
const newFileName = fileObj.name();
|
||||||
const storagePath = Avatars.storagePath({});
|
|
||||||
const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
||||||
|
|
||||||
// This is "example" variable, change it to the userId that you might be using.
|
// This is "example" variable, change it to the userId that you might be using.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue