diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-12 11:56:02 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-12 11:56:02 +0200 |
commit | f981dae8617271a2dc713bb683951730b306e0c5 (patch) | |
tree | ecee631766bc1b98c20a7836479fed40850c5a56 /server/lib/friends.ts | |
parent | 075f16caac5236cb04c98ae7b3a989766d764bb3 (diff) | |
download | PeerTube-f981dae8617271a2dc713bb683951730b306e0c5.tar.gz PeerTube-f981dae8617271a2dc713bb683951730b306e0c5.tar.zst PeerTube-f981dae8617271a2dc713bb683951730b306e0c5.zip |
Add previews cache system between pods
Diffstat (limited to 'server/lib/friends.ts')
-rw-r--r-- | server/lib/friends.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/server/lib/friends.ts b/server/lib/friends.ts index 6ed0da013..50355d5d1 100644 --- a/server/lib/friends.ts +++ b/server/lib/friends.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import * as request from 'request' | 1 | import * as request from 'request' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | import * as Promise from 'bluebird' | 3 | import * as Promise from 'bluebird' |
4 | import { join } from 'path' | ||
4 | 5 | ||
5 | import { database as db } from '../initializers/database' | 6 | import { database as db } from '../initializers/database' |
6 | import { | 7 | import { |
@@ -9,7 +10,8 @@ import { | |||
9 | REQUESTS_IN_PARALLEL, | 10 | REQUESTS_IN_PARALLEL, |
10 | REQUEST_ENDPOINTS, | 11 | REQUEST_ENDPOINTS, |
11 | REQUEST_ENDPOINT_ACTIONS, | 12 | REQUEST_ENDPOINT_ACTIONS, |
12 | REMOTE_SCHEME | 13 | REMOTE_SCHEME, |
14 | STATIC_PATHS | ||
13 | } from '../initializers' | 15 | } from '../initializers' |
14 | import { | 16 | import { |
15 | logger, | 17 | logger, |
@@ -233,6 +235,13 @@ function sendOwnedVideosToPod (podId: number) { | |||
233 | }) | 235 | }) |
234 | } | 236 | } |
235 | 237 | ||
238 | function fetchRemotePreview (pod: PodInstance, video: VideoInstance) { | ||
239 | const host = video.Author.Pod.host | ||
240 | const path = join(STATIC_PATHS.PREVIEWS, video.getPreviewName()) | ||
241 | |||
242 | return request.get(REMOTE_SCHEME.HTTP + '://' + host + path) | ||
243 | } | ||
244 | |||
236 | function getRequestScheduler () { | 245 | function getRequestScheduler () { |
237 | return requestScheduler | 246 | return requestScheduler |
238 | } | 247 | } |
@@ -263,7 +272,8 @@ export { | |||
263 | sendOwnedVideosToPod, | 272 | sendOwnedVideosToPod, |
264 | getRequestScheduler, | 273 | getRequestScheduler, |
265 | getRequestVideoQaduScheduler, | 274 | getRequestVideoQaduScheduler, |
266 | getRequestVideoEventScheduler | 275 | getRequestVideoEventScheduler, |
276 | fetchRemotePreview | ||
267 | } | 277 | } |
268 | 278 | ||
269 | // --------------------------------------------------------------------------- | 279 | // --------------------------------------------------------------------------- |