aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-20 11:05:10 +0100
committerChocobozzz <me@florianbigard.com>2017-12-20 11:05:10 +0100
commit8fa5653ad8bebed9a1b2a649e8ea160184d52408 (patch)
treeeb71b80545a89d73e9b0ef09c695b509360da85c /server
parent15ca2e871aa069e596baf9da22b3d2a1ab1a0b1a (diff)
downloadPeerTube-8fa5653ad8bebed9a1b2a649e8ea160184d52408.tar.gz
PeerTube-8fa5653ad8bebed9a1b2a649e8ea160184d52408.tar.zst
PeerTube-8fa5653ad8bebed9a1b2a649e8ea160184d52408.zip
Add transition on play/loading player
Diffstat (limited to 'server')
-rw-r--r--server/lib/cache/videos-preview-cache.ts11
-rw-r--r--server/models/video/video.ts12
2 files changed, 20 insertions, 3 deletions
diff --git a/server/lib/cache/videos-preview-cache.ts b/server/lib/cache/videos-preview-cache.ts
index c5bda8dd8..28908b186 100644
--- a/server/lib/cache/videos-preview-cache.ts
+++ b/server/lib/cache/videos-preview-cache.ts
@@ -33,7 +33,12 @@ class VideosPreviewCache {
33 }) 33 })
34 } 34 }
35 35
36 getPreviewPath (key: string) { 36 async getPreviewPath (key: string) {
37 const video = await VideoModel.loadByUUID(key)
38 if (!video) return undefined
39
40 if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName())
41
37 return new Promise<string>((res, rej) => { 42 return new Promise<string>((res, rej) => {
38 this.lru.get(key, (err, value) => { 43 this.lru.get(key, (err, value) => {
39 err ? rej(err) : res(value) 44 err ? rej(err) : res(value)
@@ -42,10 +47,10 @@ class VideosPreviewCache {
42 } 47 }
43 48
44 private async loadPreviews (key: string) { 49 private async loadPreviews (key: string) {
45 const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(key) 50 const video = await VideoModel.loadByUUID(key)
46 if (!video) return undefined 51 if (!video) return undefined
47 52
48 if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName()) 53 if (video.isOwned()) throw new Error('Cannot load preview of owned video.')
49 54
50 const res = await this.saveRemotePreviewAndReturnPath(video) 55 const res = await this.saveRemotePreviewAndReturnPath(video)
51 56
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 97fdbc8ef..8c49bc3af 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -528,6 +528,18 @@ export class VideoModel extends Model<VideoModel> {
528 .findById(id, options) 528 .findById(id, options)
529 } 529 }
530 530
531 static loadByUUID (uuid: string) {
532 const options = {
533 where: {
534 uuid
535 }
536 }
537
538 return VideoModel
539 .scope([ ScopeNames.WITH_FILES ])
540 .findOne(options)
541 }
542
531 static loadByUUIDAndPopulateAccountAndServerAndTags (uuid: string) { 543 static loadByUUIDAndPopulateAccountAndServerAndTags (uuid: string) {
532 const options = { 544 const options = {
533 order: [ [ 'Tags', 'name', 'ASC' ] ], 545 order: [ [ 'Tags', 'name', 'ASC' ] ],