mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
More robust ACL error handler
This commit is contained in:
parent
5b887a77ae
commit
bbe4910247
2 changed files with 24 additions and 7 deletions
|
@ -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()
|
||||||
|
|
|
@ -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 {
|
||||||
|
try {
|
||||||
await updateWebVideoFileACL(video, file)
|
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 {
|
||||||
|
try {
|
||||||
await updateHLSFilesACL(hls)
|
await updateHLSFilesACL(hls)
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(objectStorageErrorMsg, { err, ...lTags('object-storage', video.uuid) })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue