diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-16 09:42:22 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-02-16 10:36:44 +0100 |
commit | 374b725df52d941af1cf37cf211593340c05206c (patch) | |
tree | ec5a7805ece31b3424ea2d8e08d204074baee02d /server/models/video | |
parent | a35a22797c99f17924347da9a226068c3dbe4787 (diff) | |
download | PeerTube-374b725df52d941af1cf37cf211593340c05206c.tar.gz PeerTube-374b725df52d941af1cf37cf211593340c05206c.tar.zst PeerTube-374b725df52d941af1cf37cf211593340c05206c.zip |
Optimize remote thumbnail processing
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/thumbnail.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/server/models/video/thumbnail.ts b/server/models/video/thumbnail.ts index 3d885f654..4185ec5f2 100644 --- a/server/models/video/thumbnail.ts +++ b/server/models/video/thumbnail.ts | |||
@@ -158,6 +158,12 @@ export class ThumbnailModel extends Model { | |||
158 | return ThumbnailModel.findOne(query) | 158 | return ThumbnailModel.findOne(query) |
159 | } | 159 | } |
160 | 160 | ||
161 | static buildPath (type: ThumbnailType, filename: string) { | ||
162 | const directory = ThumbnailModel.types[type].directory | ||
163 | |||
164 | return join(directory, filename) | ||
165 | } | ||
166 | |||
161 | getFileUrl (video: MVideoAccountLight) { | 167 | getFileUrl (video: MVideoAccountLight) { |
162 | const staticPath = ThumbnailModel.types[this.type].staticPath + this.filename | 168 | const staticPath = ThumbnailModel.types[this.type].staticPath + this.filename |
163 | 169 | ||
@@ -169,13 +175,11 @@ export class ThumbnailModel extends Model { | |||
169 | } | 175 | } |
170 | 176 | ||
171 | getPath () { | 177 | getPath () { |
172 | const directory = ThumbnailModel.types[this.type].directory | 178 | return ThumbnailModel.buildPath(this.type, this.filename) |
173 | return join(directory, this.filename) | ||
174 | } | 179 | } |
175 | 180 | ||
176 | getPreviousPath () { | 181 | getPreviousPath () { |
177 | const directory = ThumbnailModel.types[this.type].directory | 182 | return ThumbnailModel.buildPath(this.type, this.previousThumbnailFilename) |
178 | return join(directory, this.previousThumbnailFilename) | ||
179 | } | 183 | } |
180 | 184 | ||
181 | removeThumbnail () { | 185 | removeThumbnail () { |