1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

More robust ACL error handler

This commit is contained in:
Chocobozzz 2025-06-24 16:02:39 +02:00
parent 5b887a77ae
commit bbe4910247
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 24 additions and 7 deletions

View file

@ -34,6 +34,8 @@ export class UpdateVideosScheduler extends AbstractScheduler {
for (const schedule of schedules) { for (const schedule of schedules) {
const videoOnly = await VideoModel.load(schedule.videoId) const videoOnly = await VideoModel.load(schedule.videoId)
if (!videoOnly) continue
const mutexReleaser = await VideoPathManager.Instance.lockFiles(videoOnly.uuid) const mutexReleaser = await VideoPathManager.Instance.lockFiles(videoOnly.uuid)
try { try {
@ -41,7 +43,7 @@ export class UpdateVideosScheduler extends AbstractScheduler {
if (published) Notifier.Instance.notifyOnVideoPublishedAfterScheduledUpdate(video) if (published) Notifier.Instance.notifyOnVideoPublishedAfterScheduledUpdate(video)
} catch (err) { } catch (err) {
logger.error('Cannot update video', { err, ...lTags(videoOnly.uuid) }) logger.error('Cannot update video ' + videoOnly.uuid, { err, ...lTags(videoOnly.uuid) })
} }
mutexReleaser() mutexReleaser()

View file

@ -1,11 +1,13 @@
import { move } from 'fs-extra/esm' import { FileStorage, VideoPrivacy, VideoPrivacyType } from '@peertube/peertube-models'
import { join } from 'path' import { logger, loggerTagsFactory } from '@server/helpers/logger.js'
import { VideoPrivacy, VideoPrivacyType, FileStorage } from '@peertube/peertube-models'
import { logger } from '@server/helpers/logger.js'
import { DIRECTORIES } from '@server/initializers/constants.js' import { DIRECTORIES } from '@server/initializers/constants.js'
import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models/index.js' import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models/index.js'
import { move } from 'fs-extra/esm'
import { join } from 'path'
import { updateHLSFilesACL, updateWebVideoFileACL } from './object-storage/index.js' import { updateHLSFilesACL, updateWebVideoFileACL } from './object-storage/index.js'
const lTags = loggerTagsFactory('video-privacy')
const validPrivacySet = new Set<VideoPrivacyType>([ const validPrivacySet = new Set<VideoPrivacyType>([
VideoPrivacy.PRIVATE, VideoPrivacy.PRIVATE,
VideoPrivacy.INTERNAL, VideoPrivacy.INTERNAL,
@ -58,11 +60,20 @@ async function moveFiles (options: {
}) { }) {
const { type, video } = options const { type, video } = options
// Catch ACL error because it doesn't break the video
// Do not catch FS error, that should not happen, because it can break the video
const objectStorageErrorMsg = 'Cannot update ACL of video file after privacy change. ' +
'Ensure your provider supports ACL or set object_storage.upload_acl.public and object_storage.upload_acl.public to null'
for (const file of video.VideoFiles) { for (const file of video.VideoFiles) {
if (file.storage === FileStorage.FILE_SYSTEM) { if (file.storage === FileStorage.FILE_SYSTEM) {
await moveWebVideoFileOnFS(type, video, file) await moveWebVideoFileOnFS(type, video, file)
} else { } else {
await updateWebVideoFileACL(video, file) try {
await updateWebVideoFileACL(video, file)
} catch (err) {
logger.error(objectStorageErrorMsg, { err, ...lTags('object-storage', video.uuid) })
}
} }
} }
@ -72,7 +83,11 @@ async function moveFiles (options: {
if (hls.storage === FileStorage.FILE_SYSTEM) { if (hls.storage === FileStorage.FILE_SYSTEM) {
await moveHLSFilesOnFS(type, video) await moveHLSFilesOnFS(type, video)
} else { } else {
await updateHLSFilesACL(hls) try {
await updateHLSFilesACL(hls)
} catch (err) {
logger.error(objectStorageErrorMsg, { err, ...lTags('object-storage', video.uuid) })
}
} }
} }
} }