]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix video import with long thumbnail url
authorChocobozzz <me@florianbigard.com>
Tue, 17 Dec 2019 08:55:33 +0000 (09:55 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 17 Dec 2019 08:55:33 +0000 (09:55 +0100)
server/initializers/constants.ts
server/initializers/migrations/0465-thumbnail-file-url-length.ts [new file with mode: 0644]
server/models/video/thumbnail.ts

index 00238f7a1cff9d888013e7a8e0e87bdb2ca86873..7e26176536320c1d69850e9bcfb315caff683fed 100644 (file)
@@ -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 (file)
index 0000000..db8c85c
--- /dev/null
@@ -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<void> {
+  {
+    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
+}
index f1952dcc1d19f647616526b96b39e33687af9d19..e68a6711fe637aa996cc6f512fae174a0c0cb0fb 100644 (file)
@@ -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<ThumbnailModel> {
   type: ThumbnailType
 
   @AllowNull(true)
-  @Column
+  @Column(DataType.STRING(CONSTRAINTS_FIELDS.COMMONS.URL.max))
   fileUrl: string
 
   @AllowNull(true)