Browse Source

feat: enable thumbnail migrations

nc-feat/enable-thumbnail-migration
mertmit 3 months ago
parent
commit
634f3d19df
  1. 6
      packages/nocodb/src/modules/jobs/migration-jobs/init-migration-jobs.ts
  2. 17
      packages/nocodb/src/modules/jobs/migration-jobs/nc_job_002_thumbnail.ts

6
packages/nocodb/src/modules/jobs/migration-jobs/init-migration-jobs.ts

@ -21,11 +21,11 @@ export class InitMigrationJobs {
job: MigrationJobTypes.Attachment, job: MigrationJobTypes.Attachment,
service: this.attachmentMigration, service: this.attachmentMigration,
}, },
/* { {
version: '2', version: '2',
job: MigrationJobTypes.Thumbnail, job: MigrationJobTypes.Thumbnail,
fn: this.thumbnailMigration.job, service: this.thumbnailMigration,
}, */ },
]; ];
private readonly debugLog = debug('nc:migration-jobs:init'); private readonly debugLog = debug('nc:migration-jobs:init');

17
packages/nocodb/src/modules/jobs/migration-jobs/nc_job_002_thumbnail.ts

@ -2,7 +2,7 @@ import path from 'path';
import debug from 'debug'; import debug from 'debug';
import { Process } from '@nestjs/bull'; import { Process } from '@nestjs/bull';
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { MigrationJobTypes } from '~/interface/Jobs'; import type Sharp from 'sharp';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import Noco from '~/Noco'; import Noco from '~/Noco';
import mimetypes from '~/utils/mimeTypes'; import mimetypes from '~/utils/mimeTypes';
@ -25,6 +25,21 @@ export class ThumbnailMigration {
@Process(MigrationJobTypes.Thumbnail) @Process(MigrationJobTypes.Thumbnail)
async job() { async job() {
try { try {
let sharp: typeof Sharp;
try {
sharp = (await import('sharp')).default;
} catch {
// ignore
}
if (!sharp) {
this.log(
`Thumbnail generation is not supported in this platform at the moment. Skipping thumbnail migration for now!`,
);
return true;
}
const ncMeta = Noco.ncMeta; const ncMeta = Noco.ncMeta;
const storageAdapter = await NcPluginMgrv2.storageAdapter(ncMeta); const storageAdapter = await NcPluginMgrv2.storageAdapter(ncMeta);

Loading…
Cancel
Save