mirror of
https://github.com/wekan/wekan.git
synced 2025-12-27 04:38:49 +01:00
Merge branch 'upgrade-meteor-2.6' of https://github.com/majus/wekan into upgrade-meteor
This commit is contained in:
commit
0c3ca14699
268 changed files with 3109 additions and 10419 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { TAPi18n } from '/imports/i18n';
|
||||
import AccountSettings from '../models/accountSettings';
|
||||
import TableVisibilityModeSettings from '../models/tableVisibilityModeSettings';
|
||||
import Actions from '../models/actions';
|
||||
|
|
@ -117,6 +118,7 @@ Migrations.add('lowercase-board-permission', () => {
|
|||
});
|
||||
});
|
||||
|
||||
/*
|
||||
// Security migration: see https://github.com/wekan/wekan/issues/99
|
||||
Migrations.add('change-attachments-type-for-non-images', () => {
|
||||
const newTypeForNonImage = 'application/octet-stream';
|
||||
|
|
@ -146,6 +148,8 @@ Migrations.add('card-covers', () => {
|
|||
Attachments.update({}, { $unset: { cover: '' } }, noValidateMulti);
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
Migrations.add('use-css-class-for-boards-colors', () => {
|
||||
const associationTable = {
|
||||
'#27AE60': 'nephritis',
|
||||
|
|
@ -1178,14 +1182,9 @@ 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`;
|
||||
if (!fs.existsSync(storagePath)) {
|
||||
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||
fs.mkdirSync(storagePath, { recursive: true });
|
||||
}
|
||||
AttachmentsOld.find().forEach(function(fileObj) {
|
||||
const newFileName = fileObj.name();
|
||||
const storagePath = Attachments.storagePath({});
|
||||
const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
||||
|
||||
// This is "example" variable, change it to the userId that you might be using.
|
||||
|
|
@ -1198,12 +1197,8 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
|||
const readStream = fileObj.createReadStream('attachments');
|
||||
const writeStream = fs.createWriteStream(filePath);
|
||||
|
||||
writeStream.on('error', error => {
|
||||
console.error('[writeStream error]: ', error, filePath);
|
||||
});
|
||||
|
||||
readStream.on('error', error => {
|
||||
console.error('[readStream error]: ', error, filePath);
|
||||
writeStream.on('error', function(err) {
|
||||
console.log('Writing error: ', err, filePath);
|
||||
});
|
||||
|
||||
// Once we have a file, then upload it to our new data storage
|
||||
|
|
@ -1221,17 +1216,16 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
|||
cardId: fileObj.cardId,
|
||||
listId: fileObj.listId,
|
||||
swimlaneId: fileObj.swimlaneId,
|
||||
source: 'import,'
|
||||
},
|
||||
userId,
|
||||
size: fileSize,
|
||||
fileId,
|
||||
},
|
||||
(error, fileRef) => {
|
||||
if (error) {
|
||||
console.error('[Attachments#addFile error]: ', error);
|
||||
(err, fileRef) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('File Inserted: ', fileRef);
|
||||
console.log('File Inserted: ', fileRef._id);
|
||||
// Set the userId again
|
||||
Attachments.update({ _id: fileRef._id }, { $set: { userId } });
|
||||
fileObj.remove();
|
||||
|
|
@ -1241,19 +1235,18 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
|||
); // proceedAfterUpload
|
||||
});
|
||||
|
||||
readStream.on('error', error => {
|
||||
console.log('Error: ', filePath, error);
|
||||
});
|
||||
|
||||
readStream.pipe(writeStream);
|
||||
});
|
||||
});
|
||||
|
||||
Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
|
||||
//const storagePath = Avatars.storagePath();
|
||||
const storagePath = process.env.WRITABLE_PATH || `./wekan-uploads`;
|
||||
if (!fs.existsSync(storagePath)) {
|
||||
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||
fs.mkdirSync(storagePath, { recursive: true });
|
||||
}
|
||||
AvatarsOld.find().forEach(function(fileObj) {
|
||||
const newFileName = fileObj.name();
|
||||
const storagePath = Avatars.storagePath({});
|
||||
const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
||||
|
||||
// This is "example" variable, change it to the userId that you might be using.
|
||||
|
|
@ -1266,12 +1259,8 @@ Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
|
|||
const readStream = fileObj.createReadStream('avatars');
|
||||
const writeStream = fs.createWriteStream(filePath);
|
||||
|
||||
writeStream.on('error', error => {
|
||||
console.error('[writeStream error]: ', error, filePath);
|
||||
});
|
||||
|
||||
readStream.on('error', error => {
|
||||
console.error('[readStream error]: ', error, filePath);
|
||||
writeStream.on('error', function(err) {
|
||||
console.log('Writing error: ', err, filePath);
|
||||
});
|
||||
|
||||
// Once we have a file, then upload it to our new data storage
|
||||
|
|
@ -1294,11 +1283,11 @@ Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
|
|||
size: fileSize,
|
||||
fileId,
|
||||
},
|
||||
(error, fileRef) => {
|
||||
if (error) {
|
||||
console.error('[Avatars#addFile error]: ', error);
|
||||
(err, fileRef) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log('File Inserted: ', newFileName, fileRef);
|
||||
console.log('File Inserted: ', newFileName, fileRef._id);
|
||||
// Set the userId again
|
||||
Avatars.update({ _id: fileRef._id }, { $set: { userId } });
|
||||
Users.find().forEach(user => {
|
||||
|
|
@ -1324,13 +1313,10 @@ Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
|
|||
);
|
||||
});
|
||||
|
||||
readStream.on('error', error => {
|
||||
console.log('Error: ', filePath, error);
|
||||
});
|
||||
|
||||
readStream.pipe(writeStream);
|
||||
});
|
||||
});
|
||||
|
||||
Migrations.add('migrate-attachment-drop-index-cardId', () => {
|
||||
try {
|
||||
Attachments.collection._dropIndex({'cardId': 1});
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue