Fix video file object storage detection

This commit is contained in:
Chocobozzz 2024-08-19 17:02:44 +02:00
parent dc151d3f51
commit 27bf92235f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 43 additions and 5 deletions

View File

@ -2,7 +2,8 @@ import { DatePipe, NgClass, NgFor, NgIf } from '@angular/common'
import { Component, OnInit, ViewChild } from '@angular/core'
import { ActivatedRoute, Router, RouterLink } from '@angular/router'
import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
import { formatICU, getAbsoluteAPIUrl } from '@app/helpers'
import { formatICU } from '@app/helpers'
import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
import { VideoFileTokenService } from '@app/shared/shared-main/video/video-file-token.service'
import { Video } from '@app/shared/shared-main/video/video.model'
@ -11,7 +12,7 @@ import { VideoBlockComponent } from '@app/shared/shared-moderation/video-block.c
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'
import { getAllFiles } from '@peertube/peertube-core-utils'
import { UserRight, VideoFile, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@peertube/peertube-models'
import { FileStorage, UserRight, VideoFile, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@peertube/peertube-models'
import { videoRequiresFileToken } from '@root-helpers/video'
import { SharedModule, SortMeta } from 'primeng/api'
import { TableModule, TableRowExpandEvent } from 'primeng/table'
@ -30,7 +31,6 @@ import {
VideoActionsDropdownComponent
} from '../../../shared/shared-video-miniature/video-actions-dropdown.component'
import { VideoAdminService } from './video-admin.service'
import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'
@Component({
selector: 'my-video-list',
@ -230,7 +230,7 @@ export class VideoListComponent extends RestTable <Video> implements OnInit {
const files = getAllFiles(video)
return files.some(f => !f.fileUrl.startsWith(getAbsoluteAPIUrl()))
return files.some(f => f.storage === FileStorage.OBJECT_STORAGE)
}
canRemoveOneFile (video: Video) {

View File

@ -1,3 +1,4 @@
import { FileStorageType } from '../../common/file-storage.enum.js'
import { VideoConstant } from '../video-constant.model.js'
import { VideoFileMetadata } from './video-file-metadata.model.js'
@ -25,4 +26,6 @@ export interface VideoFile {
hasAudio: boolean
hasVideo: boolean
storage: FileStorageType
}

View File

@ -2,6 +2,7 @@
import { getHLS, removeFragmentedMP4Ext, uuidRegex } from '@peertube/peertube-core-utils'
import {
FileStorage,
HttpStatusCode,
VideoDetails,
VideoPrivacy,
@ -235,6 +236,12 @@ export async function completeCheckHlsPlaylist (options: {
expect(Math.max(file.height, file.width)).to.be.greaterThan(resolution)
}
if (objectStorageBaseUrl) {
expect(file.storage).to.equal(FileStorage.OBJECT_STORAGE)
} else {
expect(file.storage).to.equal(FileStorage.FILE_SYSTEM)
}
expect(file.magnetUri).to.have.lengthOf.above(2)
await checkWebTorrentWorks(file.magnetUri)

View File

@ -3,6 +3,7 @@
import { uuidRegex } from '@peertube/peertube-core-utils'
import { ffprobePromise } from '@peertube/peertube-ffmpeg'
import {
FileStorage,
HttpStatusCode,
HttpStatusCodeType,
VideoCaption,
@ -63,6 +64,12 @@ export async function completeWebVideoFilesCheck (options: {
expect(file.id).to.exist
expect(file.magnetUri).to.have.lengthOf.above(2)
if (objectStorageBaseUrl) {
expect(file.storage).to.equal(FileStorage.OBJECT_STORAGE)
} else {
expect(file.storage).to.equal(FileStorage.FILE_SYSTEM)
}
{
const privatePath = requiresAuth
? 'private/'

View File

@ -258,7 +258,9 @@ export function videoFilesModelToFormattedJSON (
metadataUrl: videoFile.metadataUrl ?? getLocalVideoFileMetadataUrl(video, videoFile),
hasAudio: videoFile.hasAudio(),
hasVideo: videoFile.hasVideo()
hasVideo: videoFile.hasVideo(),
storage: videoFile.storage
}
})
}

View File

@ -8188,6 +8188,15 @@ components:
type: string
format: url
description: URL dereferencing the output of ffprobe on the file
hasAudio:
type: boolean
description: "**PeerTube >= 6.2** The file container has an audio stream"
hasVideo:
type: boolean
description: "**PeerTube >= 6.2** The file container has a video stream"
storage:
$ref: '#/components/schemas/FileStorage'
VideoStreamingPlaylists:
allOf:
- type: object
@ -11248,6 +11257,16 @@ components:
items:
$ref: "#/components/schemas/VideoPassword/properties/password"
uniqueItems: true
FileStorage:
type: integer
enum:
- 0
- 1
description: >
The file storage type:
- `0` File system
- `1` Object storage
callbacks:
searchIndex:
'https://search.example.org/api/v1/search/videos':