aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+admin/overview/videos/video-list.component.html2
-rw-r--r--client/src/app/+admin/overview/videos/video-list.component.ts4
-rw-r--r--client/src/app/shared/shared-main/video/video.model.ts11
-rw-r--r--server/tests/api/live/live.ts4
-rw-r--r--server/tests/api/transcoding/transcoder.ts4
-rw-r--r--server/tests/api/transcoding/video-studio.ts4
-rw-r--r--server/tests/cli/update-host.ts2
-rw-r--r--server/tests/shared/videos.ts13
-rw-r--r--shared/core-utils/videos/privacy.ts14
9 files changed, 36 insertions, 22 deletions
diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html
index 06b9ab347..14bbb55e9 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.html
+++ b/client/src/app/+admin/overview/videos/video-list.component.html
@@ -109,6 +109,7 @@
109 {{ file.resolution.label }}: {{ file.size | bytes: 1 }} 109 {{ file.resolution.label }}: {{ file.size | bytes: 1 }}
110 110
111 <my-global-icon 111 <my-global-icon
112 *ngIf="canRemoveOneFile(video)"
112 i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button" 113 i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button"
113 (click)="removeVideoFile(video, file, 'webtorrent')" 114 (click)="removeVideoFile(video, file, 'webtorrent')"
114 ></my-global-icon> 115 ></my-global-icon>
@@ -124,6 +125,7 @@
124 {{ file.resolution.label }}: {{ file.size | bytes: 1 }} 125 {{ file.resolution.label }}: {{ file.size | bytes: 1 }}
125 126
126 <my-global-icon 127 <my-global-icon
128 *ngIf="canRemoveOneFile(video)"
127 i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button" 129 i18n-ngbTooltip ngbTooltip="Delete this file" iconName="delete" role="button"
128 (click)="removeVideoFile(video, file, 'hls')" 130 (click)="removeVideoFile(video, file, 'hls')"
129 ></my-global-icon> 131 ></my-global-icon>
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts
index ed7ec54a1..cb693ce12 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.ts
+++ b/client/src/app/+admin/overview/videos/video-list.component.ts
@@ -166,6 +166,10 @@ export class VideoListComponent extends RestTable implements OnInit {
166 return video.files.length !== 0 166 return video.files.length !== 0
167 } 167 }
168 168
169 canRemoveOneFile (video: Video) {
170 return video.canRemoveOneFile(this.authUser)
171 }
172
169 getFilesSize (video: Video) { 173 getFilesSize (video: Video) {
170 let files = video.files 174 let files = video.files
171 175
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 2e4ab87d7..c9c6b979c 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -1,8 +1,8 @@
1import { AuthUser } from '@app/core' 1import { AuthUser } from '@app/core'
2import { User } from '@app/core/users/user.model' 2import { User } from '@app/core/users/user.model'
3import { durationToString, prepareIcu, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' 3import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl, prepareIcu } from '@app/helpers'
4import { Actor } from '@app/shared/shared-main/account/actor.model' 4import { Actor } from '@app/shared/shared-main/account/actor.model'
5import { buildVideoWatchPath } from '@shared/core-utils' 5import { buildVideoWatchPath, getAllFiles } from '@shared/core-utils'
6import { peertubeTranslate } from '@shared/core-utils/i18n' 6import { peertubeTranslate } from '@shared/core-utils/i18n'
7import { 7import {
8 ActorImage, 8 ActorImage,
@@ -240,6 +240,13 @@ export class Video implements VideoServerModel {
240 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS)) 240 return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.SEE_ALL_VIDEOS))
241 } 241 }
242 242
243 canRemoveOneFile (user: AuthUser) {
244 return this.isLocal &&
245 user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&
246 this.state.id !== VideoState.TO_TRANSCODE &&
247 getAllFiles(this).length > 1
248 }
249
243 canRemoveFiles (user: AuthUser) { 250 canRemoveFiles (user: AuthUser) {
244 return this.isLocal && 251 return this.isLocal &&
245 user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) && 252 user && user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 48982f4de..885751285 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -3,8 +3,8 @@
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { basename, join } from 'path' 4import { basename, join } from 'path'
5import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' 5import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg'
6import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, getAllFiles, testImage } from '@server/tests/shared' 6import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared'
7import { wait } from '@shared/core-utils' 7import { getAllFiles, wait } from '@shared/core-utils'
8import { 8import {
9 HttpStatusCode, 9 HttpStatusCode,
10 LiveVideo, 10 LiveVideo,
diff --git a/server/tests/api/transcoding/transcoder.ts b/server/tests/api/transcoding/transcoder.ts
index db0127805..c591f5f6f 100644
--- a/server/tests/api/transcoding/transcoder.ts
+++ b/server/tests/api/transcoding/transcoder.ts
@@ -2,8 +2,8 @@
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { canDoQuickTranscode } from '@server/helpers/ffmpeg' 4import { canDoQuickTranscode } from '@server/helpers/ffmpeg'
5import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared' 5import { generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared'
6import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate, omit } from '@shared/core-utils' 6import { buildAbsoluteFixturePath, getAllFiles, getMaxBitrate, getMinLimitBitrate, omit } from '@shared/core-utils'
7import { 7import {
8 buildFileMetadata, 8 buildFileMetadata,
9 getAudioStream, 9 getAudioStream,
diff --git a/server/tests/api/transcoding/video-studio.ts b/server/tests/api/transcoding/video-studio.ts
index ac1c0fc7e..9613111b5 100644
--- a/server/tests/api/transcoding/video-studio.ts
+++ b/server/tests/api/transcoding/video-studio.ts
@@ -1,6 +1,6 @@
1import { expect } from 'chai' 1import { expect } from 'chai'
2import { expectStartWith, getAllFiles } from '@server/tests/shared' 2import { expectStartWith } from '@server/tests/shared'
3import { areObjectStorageTestsDisabled } from '@shared/core-utils' 3import { areObjectStorageTestsDisabled, getAllFiles } from '@shared/core-utils'
4import { VideoStudioTask } from '@shared/models' 4import { VideoStudioTask } from '@shared/models'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index 53c4e7824..97632450a 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -1,6 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { getAllFiles } from '@shared/core-utils'
4import { 5import {
5 cleanupTests, 6 cleanupTests,
6 createSingleServer, 7 createSingleServer,
@@ -11,7 +12,6 @@ import {
11 setAccessTokensToServers, 12 setAccessTokensToServers,
12 waitJobs 13 waitJobs
13} from '@shared/server-commands' 14} from '@shared/server-commands'
14import { getAllFiles } from '../shared'
15 15
16describe('Test update host scripts', function () { 16describe('Test update host scripts', function () {
17 let server: PeerTubeServer 17 let server: PeerTubeServer
diff --git a/server/tests/shared/videos.ts b/server/tests/shared/videos.ts
index 3ab245392..e18329e07 100644
--- a/server/tests/shared/videos.ts
+++ b/server/tests/shared/videos.ts
@@ -241,16 +241,6 @@ async function uploadRandomVideoOnServers (
241 return res 241 return res
242} 242}
243 243
244function getAllFiles (video: VideoDetails) {
245 const files = video.files
246
247 if (video.streamingPlaylists[0]) {
248 return files.concat(video.streamingPlaylists[0].files)
249 }
250
251 return files
252}
253
254// --------------------------------------------------------------------------- 244// ---------------------------------------------------------------------------
255 245
256export { 246export {
@@ -258,6 +248,5 @@ export {
258 checkUploadVideoParam, 248 checkUploadVideoParam,
259 uploadRandomVideoOnServers, 249 uploadRandomVideoOnServers,
260 checkVideoFilesWereRemoved, 250 checkVideoFilesWereRemoved,
261 saveVideoInServers, 251 saveVideoInServers
262 getAllFiles
263} 252}
diff --git a/shared/core-utils/videos/privacy.ts b/shared/core-utils/videos/privacy.ts
index 7d3b67d50..f33487b49 100644
--- a/shared/core-utils/videos/privacy.ts
+++ b/shared/core-utils/videos/privacy.ts
@@ -1,9 +1,21 @@
1import { VideoDetails } from '../../models/videos/video.model'
1import { VideoPrivacy } from '../../models/videos/video-privacy.enum' 2import { VideoPrivacy } from '../../models/videos/video-privacy.enum'
2 3
3function getAllPrivacies () { 4function getAllPrivacies () {
4 return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ] 5 return [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL, VideoPrivacy.PRIVATE, VideoPrivacy.UNLISTED ]
5} 6}
6 7
8function getAllFiles (video: Partial<Pick<VideoDetails, 'files' | 'streamingPlaylists'>>) {
9 const files = video.files
10
11 if (video.streamingPlaylists[0]) {
12 return files.concat(video.streamingPlaylists[0].files)
13 }
14
15 return files
16}
17
7export { 18export {
8 getAllPrivacies 19 getAllPrivacies,
20 getAllFiles
9} 21}