aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-12 16:23:19 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-16 10:36:44 +0100
commita8b1b40485145ac1eae513a661d7dd6e0986ce96 (patch)
tree79436a042f1ed350278dd69e365f37ee623aa539 /server/initializers
parent0472d474fdadd05211fb4f90ce275801db515d08 (diff)
downloadPeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.tar.gz
PeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.tar.zst
PeerTube-a8b1b40485145ac1eae513a661d7dd6e0986ce96.zip
Generate a name for thumbnails
Allows aggressive caching
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0575-duplicate-thumbnail.ts24
2 files changed, 25 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 7beaca238..a9f7a8e58 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
24 24
25// --------------------------------------------------------------------------- 25// ---------------------------------------------------------------------------
26 26
27const LAST_MIGRATION_VERSION = 570 27const LAST_MIGRATION_VERSION = 575
28 28
29// --------------------------------------------------------------------------- 29// ---------------------------------------------------------------------------
30 30
diff --git a/server/initializers/migrations/0575-duplicate-thumbnail.ts b/server/initializers/migrations/0575-duplicate-thumbnail.ts
new file mode 100644
index 000000000..4dbbe71d4
--- /dev/null
+++ b/server/initializers/migrations/0575-duplicate-thumbnail.ts
@@ -0,0 +1,24 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7 db: any
8}): Promise<void> {
9 {
10 const query = 'DELETE FROM "thumbnail" s1 ' +
11 'USING (SELECT MIN(id) as id, "filename", "type" FROM "thumbnail" GROUP BY "filename", "type" HAVING COUNT(*) > 1) s2 ' +
12 'WHERE s1."filename" = s2."filename" AND s1."type" = s2."type" AND s1.id <> s2.id'
13 await utils.sequelize.query(query)
14 }
15}
16
17function down (options) {
18 throw new Error('Not implemented.')
19}
20
21export {
22 up,
23 down
24}