aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-11 11:39:59 +0200
committerChocobozzz <me@florianbigard.com>2023-07-11 11:39:59 +0200
commit34555bebf8e2a2caf2cb1cfd85280d140fcc3802 (patch)
tree9c5e5eb78891bb09d23ae3fe37fe3db69bb8a2d9 /server
parentd732ec7b46caa2a0972f132894023fec6bc5dd6a (diff)
downloadPeerTube-34555bebf8e2a2caf2cb1cfd85280d140fcc3802.tar.gz
PeerTube-34555bebf8e2a2caf2cb1cfd85280d140fcc3802.tar.zst
PeerTube-34555bebf8e2a2caf2cb1cfd85280d140fcc3802.zip
Migrate from webseed to web-videos
Diffstat (limited to 'server')
-rw-r--r--server/controllers/object-storage-proxy.ts3
-rw-r--r--server/controllers/static.ts4
-rw-r--r--server/initializers/constants.ts13
-rw-r--r--server/lib/object-storage/urls.ts2
-rw-r--r--server/models/video/video-file.ts4
-rw-r--r--server/tests/api/object-storage/video-static-file-privacy.ts4
-rw-r--r--server/tests/api/redundancy/redundancy.ts4
-rw-r--r--server/tests/api/videos/video-static-file-privacy.ts2
-rw-r--r--server/tests/shared/videos.ts5
9 files changed, 25 insertions, 16 deletions
diff --git a/server/controllers/object-storage-proxy.ts b/server/controllers/object-storage-proxy.ts
index 0edde64fe..d0c59bf93 100644
--- a/server/controllers/object-storage-proxy.ts
+++ b/server/controllers/object-storage-proxy.ts
@@ -15,7 +15,8 @@ const objectStorageProxyRouter = express.Router()
15 15
16objectStorageProxyRouter.use(cors()) 16objectStorageProxyRouter.use(cors())
17 17
18objectStorageProxyRouter.get(OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEBSEED + ':filename', 18objectStorageProxyRouter.get(
19 [ OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEB_VIDEOS + ':filename', OBJECT_STORAGE_PROXY_PATHS.LEGACY_PRIVATE_WEB_VIDEOS + ':filename' ],
19 ensurePrivateObjectStorageProxyIsEnabled, 20 ensurePrivateObjectStorageProxyIsEnabled,
20 optionalAuthenticate, 21 optionalAuthenticate,
21 asyncMiddleware(ensureCanAccessVideoPrivateWebVideoFiles), 22 asyncMiddleware(ensureCanAccessVideoPrivateWebVideoFiles),
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 5ce739bfc..97caa8292 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -29,13 +29,13 @@ const privateWebVideoStaticMiddlewares = CONFIG.STATIC_FILES.PRIVATE_FILES_REQUI
29 : [] 29 : []
30 30
31staticRouter.use( 31staticRouter.use(
32 STATIC_PATHS.PRIVATE_WEBSEED, 32 [ STATIC_PATHS.PRIVATE_WEB_VIDEOS, STATIC_PATHS.LEGACY_PRIVATE_WEB_VIDEOS ],
33 ...privateWebVideoStaticMiddlewares, 33 ...privateWebVideoStaticMiddlewares,
34 express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }), 34 express.static(DIRECTORIES.VIDEOS.PRIVATE, { fallthrough: false }),
35 handleStaticError 35 handleStaticError
36) 36)
37staticRouter.use( 37staticRouter.use(
38 STATIC_PATHS.WEBSEED, 38 [ STATIC_PATHS.WEB_VIDEOS, STATIC_PATHS.LEGACY_WEB_VIDEOS ],
39 express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }), 39 express.static(DIRECTORIES.VIDEOS.PUBLIC, { fallthrough: false }),
40 handleStaticError 40 handleStaticError
41) 41)
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 5116c6396..03ae94d35 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -750,8 +750,13 @@ const STATIC_PATHS = {
750 // TODO: deprecated in v6, to remove 750 // TODO: deprecated in v6, to remove
751 THUMBNAILS: '/static/thumbnails/', 751 THUMBNAILS: '/static/thumbnails/',
752 752
753 WEBSEED: '/static/webseed/', 753 // Need to keep this legacy path for previously generated torrents
754 PRIVATE_WEBSEED: '/static/webseed/private/', 754 LEGACY_WEB_VIDEOS: '/static/webseed/',
755 WEB_VIDEOS: '/static/web-videos/',
756
757 // Need to keep this legacy path for previously generated torrents
758 LEGACY_PRIVATE_WEB_VIDEOS: '/static/webseed/private/',
759 PRIVATE_WEB_VIDEOS: '/static/web-videos/private/',
755 760
756 REDUNDANCY: '/static/redundancy/', 761 REDUNDANCY: '/static/redundancy/',
757 762
@@ -775,7 +780,9 @@ const LAZY_STATIC_PATHS = {
775 STORYBOARDS: '/lazy-static/storyboards/' 780 STORYBOARDS: '/lazy-static/storyboards/'
776} 781}
777const OBJECT_STORAGE_PROXY_PATHS = { 782const OBJECT_STORAGE_PROXY_PATHS = {
778 PRIVATE_WEBSEED: '/object-storage-proxy/webseed/private/', 783 // Need to keep this legacy path for previously generated torrents
784 LEGACY_PRIVATE_WEB_VIDEOS: '/object-storage-proxy/webseed/private/',
785 PRIVATE_WEB_VIDEOS: '/object-storage-proxy/web-videos/private/',
779 786
780 STREAMING_PLAYLISTS: { 787 STREAMING_PLAYLISTS: {
781 PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/' 788 PRIVATE_HLS: '/object-storage-proxy/streaming-playlists/hls/private/'
diff --git a/server/lib/object-storage/urls.ts b/server/lib/object-storage/urls.ts
index d25f84026..40619cd5a 100644
--- a/server/lib/object-storage/urls.ts
+++ b/server/lib/object-storage/urls.ts
@@ -30,7 +30,7 @@ function getHLSPrivateFileUrl (video: MVideoUUID, filename: string) {
30} 30}
31 31
32function getWebVideoPrivateFileUrl (filename: string) { 32function getWebVideoPrivateFileUrl (filename: string) {
33 return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEBSEED + filename 33 return WEBSERVER.URL + OBJECT_STORAGE_PROXY_PATHS.PRIVATE_WEB_VIDEOS + filename
34} 34}
35 35
36// --------------------------------------------------------------------------- 36// ---------------------------------------------------------------------------
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 5e476f3c7..ee34ad2ff 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -558,10 +558,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
558 558
559 private getWebVideoFileStaticPath (video: MVideo) { 559 private getWebVideoFileStaticPath (video: MVideo) {
560 if (isVideoInPrivateDirectory(video.privacy)) { 560 if (isVideoInPrivateDirectory(video.privacy)) {
561 return join(STATIC_PATHS.PRIVATE_WEBSEED, this.filename) 561 return join(STATIC_PATHS.PRIVATE_WEB_VIDEOS, this.filename)
562 } 562 }
563 563
564 return join(STATIC_PATHS.WEBSEED, this.filename) 564 return join(STATIC_PATHS.WEB_VIDEOS, this.filename)
565 } 565 }
566 566
567 private getHLSFileStaticPath (video: MVideo) { 567 private getHLSFileStaticPath (video: MVideo) {
diff --git a/server/tests/api/object-storage/video-static-file-privacy.ts b/server/tests/api/object-storage/video-static-file-privacy.ts
index 18d30a2f5..64ab542a5 100644
--- a/server/tests/api/object-storage/video-static-file-privacy.ts
+++ b/server/tests/api/object-storage/video-static-file-privacy.ts
@@ -39,7 +39,7 @@ describe('Object storage for video static file privacy', function () {
39 const video = await server.videos.getWithToken({ id: uuid }) 39 const video = await server.videos.getWithToken({ id: uuid })
40 40
41 for (const file of video.files) { 41 for (const file of video.files) {
42 expectStartWith(file.fileUrl, server.url + '/object-storage-proxy/webseed/private/') 42 expectStartWith(file.fileUrl, server.url + '/object-storage-proxy/web-videos/private/')
43 43
44 await makeRawRequest({ url: file.fileUrl, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) 44 await makeRawRequest({ url: file.fileUrl, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
45 } 45 }
@@ -538,7 +538,7 @@ describe('Object storage for video static file privacy', function () {
538 const hlsFilename = extractFilenameFromUrl(getHLS(privateVideo).files[0].fileUrl) 538 const hlsFilename = extractFilenameFromUrl(getHLS(privateVideo).files[0].fileUrl)
539 539
540 await makeRawRequest({ 540 await makeRawRequest({
541 url: server.url + '/object-storage-proxy/webseed/private/' + webVideoFilename, 541 url: server.url + '/object-storage-proxy/web-videos/private/' + webVideoFilename,
542 token: server.accessToken, 542 token: server.accessToken,
543 expectedStatus: HttpStatusCode.BAD_REQUEST_400 543 expectedStatus: HttpStatusCode.BAD_REQUEST_400
544 }) 544 })
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 85da6acf5..0c5c27225 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -125,7 +125,7 @@ async function check1WebSeed (videoUUID?: string) {
125 if (!videoUUID) videoUUID = video1Server2.uuid 125 if (!videoUUID) videoUUID = video1Server2.uuid
126 126
127 const webseeds = [ 127 const webseeds = [
128 `${servers[1].url}/static/webseed/` 128 `${servers[1].url}/static/web-videos/`
129 ] 129 ]
130 130
131 for (const server of servers) { 131 for (const server of servers) {
@@ -145,7 +145,7 @@ async function check2Webseeds (videoUUID?: string) {
145 145
146 const webseeds = [ 146 const webseeds = [
147 `${servers[0].url}/static/redundancy/`, 147 `${servers[0].url}/static/redundancy/`,
148 `${servers[1].url}/static/webseed/` 148 `${servers[1].url}/static/web-videos/`
149 ] 149 ]
150 150
151 for (const server of servers) { 151 for (const server of servers) {
diff --git a/server/tests/api/videos/video-static-file-privacy.ts b/server/tests/api/videos/video-static-file-privacy.ts
index ec4c697db..0a9864134 100644
--- a/server/tests/api/videos/video-static-file-privacy.ts
+++ b/server/tests/api/videos/video-static-file-privacy.ts
@@ -41,7 +41,7 @@ describe('Test video static file privacy', function () {
41 41
42 for (const file of video.files) { 42 for (const file of video.files) {
43 expect(file.fileDownloadUrl).to.not.include('/private/') 43 expect(file.fileDownloadUrl).to.not.include('/private/')
44 expectStartWith(file.fileUrl, server.url + '/static/webseed/private/') 44 expectStartWith(file.fileUrl, server.url + '/static/web-videos/private/')
45 45
46 const torrent = await parseTorrentVideo(server, file) 46 const torrent = await parseTorrentVideo(server, file)
47 expect(torrent.urlList).to.have.lengthOf(0) 47 expect(torrent.urlList).to.have.lengthOf(0)
diff --git a/server/tests/shared/videos.ts b/server/tests/shared/videos.ts
index b7f7a1613..e09bd60b5 100644
--- a/server/tests/shared/videos.ts
+++ b/server/tests/shared/videos.ts
@@ -51,11 +51,12 @@ async function completeWebVideoFilesCheck (options: {
51 expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`)) 51 expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`))
52 52
53 if (objectStorageBaseUrl && requiresAuth) { 53 if (objectStorageBaseUrl && requiresAuth) {
54 expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/object-storage-proxy/webseed/${privatePath}${nameReg}${extension}`)) 54 const regexp = new RegExp(`${originServer.url}/object-storage-proxy/web-videos/${privatePath}${nameReg}${extension}`)
55 expect(file.fileUrl).to.match(regexp)
55 } else if (objectStorageBaseUrl) { 56 } else if (objectStorageBaseUrl) {
56 expectStartWith(file.fileUrl, objectStorageBaseUrl) 57 expectStartWith(file.fileUrl, objectStorageBaseUrl)
57 } else { 58 } else {
58 expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/static/webseed/${privatePath}${nameReg}${extension}`)) 59 expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/static/web-videos/${privatePath}${nameReg}${extension}`))
59 } 60 }
60 61
61 expect(file.fileDownloadUrl).to.match(new RegExp(`${originServer.url}/download/videos/${nameReg}${extension}`)) 62 expect(file.fileDownloadUrl).to.match(new RegExp(`${originServer.url}/download/videos/${nameReg}${extension}`))