mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
WRITABLE_PATH is mandatory, so simplify the code logic
This commit is contained in:
parent
d63f1b740c
commit
927f155078
3 changed files with 6 additions and 12 deletions
|
|
@ -28,10 +28,8 @@ Attachments = new FilesCollection({
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
storagePath() {
|
storagePath() {
|
||||||
if (process.env.WRITABLE_PATH) {
|
const ret = path.join(process.env.WRITABLE_PATH, 'attachments');
|
||||||
return path.join(process.env.WRITABLE_PATH, 'uploads', 'attachments');
|
return ret;
|
||||||
}
|
|
||||||
return path.normalize(`assets/app/uploads/${this.collectionName}`);
|
|
||||||
},
|
},
|
||||||
onAfterUpload(fileObj) {
|
onAfterUpload(fileObj) {
|
||||||
Object.keys(fileObj.versions).forEach(versionName => {
|
Object.keys(fileObj.versions).forEach(versionName => {
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,8 @@ Avatars = new FilesCollection({
|
||||||
collectionName: 'avatars',
|
collectionName: 'avatars',
|
||||||
allowClientCode: true,
|
allowClientCode: true,
|
||||||
storagePath() {
|
storagePath() {
|
||||||
if (process.env.WRITABLE_PATH) {
|
const ret = path.join(process.env.WRITABLE_PATH, 'avatars');
|
||||||
return path.join(process.env.WRITABLE_PATH, 'uploads', 'avatars');
|
return ret;
|
||||||
}
|
|
||||||
return path.normalize(`assets/app/uploads/${this.collectionName}`);;
|
|
||||||
},
|
},
|
||||||
onBeforeUpload(file) {
|
onBeforeUpload(file) {
|
||||||
if (file.size <= 72000 && file.type.startsWith('image/')) {
|
if (file.size <= 72000 && file.type.startsWith('image/')) {
|
||||||
|
|
|
||||||
|
|
@ -1178,8 +1178,7 @@ 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();
|
const storagePath = Attachments.storagePath();
|
||||||
const storagePath = process.env.WRITABLE_PATH || `./wekan-uploads`;
|
|
||||||
if (!fs.existsSync(storagePath)) {
|
if (!fs.existsSync(storagePath)) {
|
||||||
console.log("create storagePath because it doesn't exist: " + storagePath);
|
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||||
fs.mkdirSync(storagePath, { recursive: true });
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
|
@ -1246,8 +1245,7 @@ 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();
|
const storagePath = Avatars.storagePath();
|
||||||
const storagePath = process.env.WRITABLE_PATH || `./wekan-uploads`;
|
|
||||||
if (!fs.existsSync(storagePath)) {
|
if (!fs.existsSync(storagePath)) {
|
||||||
console.log("create storagePath because it doesn't exist: " + storagePath);
|
console.log("create storagePath because it doesn't exist: " + storagePath);
|
||||||
fs.mkdirSync(storagePath, { recursive: true });
|
fs.mkdirSync(storagePath, { recursive: true });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue