From 2735a154dc77316e584bc784c65e904df791067f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 17 Dec 2019 09:55:33 +0100 Subject: [PATCH] Fix video import with long thumbnail url --- server/initializers/constants.ts | 5 +++- .../0465-thumbnail-file-url-length.ts | 27 +++++++++++++++++++ server/models/video/thumbnail.ts | 18 ++++++++++--- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 server/initializers/migrations/0465-thumbnail-file-url-length.ts diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 00238f7a1..7e2617653 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 460 +const LAST_MIGRATION_VERSION = 465 // --------------------------------------------------------------------------- @@ -291,6 +291,9 @@ const CONSTRAINTS_FIELDS = { PLUGINS: { NAME: { min: 1, max: 214 }, // Length DESCRIPTION: { min: 1, max: 20000 } // Length + }, + COMMONS: { + URL: { min: 5, max: 2000 } // Length } } diff --git a/server/initializers/migrations/0465-thumbnail-file-url-length.ts b/server/initializers/migrations/0465-thumbnail-file-url-length.ts new file mode 100644 index 000000000..db8c85c29 --- /dev/null +++ b/server/initializers/migrations/0465-thumbnail-file-url-length.ts @@ -0,0 +1,27 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize, + db: any +}): Promise { + { + const data = { + type: Sequelize.STRING(2000), + allowNull: true, + defaultValue: null + } + + await utils.queryInterface.changeColumn('thumbnail', 'fileUrl', data) + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} diff --git a/server/models/video/thumbnail.ts b/server/models/video/thumbnail.ts index f1952dcc1..e68a6711f 100644 --- a/server/models/video/thumbnail.ts +++ b/server/models/video/thumbnail.ts @@ -1,6 +1,18 @@ import { join } from 'path' -import { AfterDestroy, AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' -import { LAZY_STATIC_PATHS, STATIC_PATHS, WEBSERVER } from '../../initializers/constants' +import { + AfterDestroy, + AllowNull, + BelongsTo, + Column, + CreatedAt, + DataType, + Default, + ForeignKey, + Model, + Table, + UpdatedAt +} from 'sequelize-typescript' +import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, STATIC_PATHS, WEBSERVER } from '../../initializers/constants' import { logger } from '../../helpers/logger' import { remove } from 'fs-extra' import { CONFIG } from '../../initializers/config' @@ -41,7 +53,7 @@ export class ThumbnailModel extends Model { type: ThumbnailType @AllowNull(true) - @Column + @Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max)) fileUrl: string @AllowNull(true)