From: Chocobozzz Date: Tue, 17 Dec 2019 08:55:33 +0000 (+0100) Subject: Fix video import with long thumbnail url X-Git-Tag: v2.1.0-rc.1~195 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2735a154dc77316e584bc784c65e904df791067f;p=oweals%2Fpeertube.git Fix video import with long thumbnail url --- 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)