Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

More robust ACL error handler

Chocobozzzbbe49102477c
diff --git a/server/core/lib/schedulers/update-videos-scheduler.ts b/server/core/lib/schedulers/update-videos-scheduler.ts
index cda39e580d..457ccc8ea6 100644
--- a/server/core/lib/schedulers/update-videos-scheduler.ts
+++ b/server/core/lib/schedulers/update-videos-scheduler.ts
@@ -34,6 +34,8 @@ export class UpdateVideosScheduler extends AbstractScheduler {
for (const schedule of schedules) {
const videoOnly = await VideoModel.load(schedule.videoId)
+ if (!videoOnly) continue
+
const mutexReleaser = await VideoPathManager.Instance.lockFiles(videoOnly.uuid)
try {
@@ -41,7 +43,7 @@ export class UpdateVideosScheduler extends AbstractScheduler {
if (published) Notifier.Instance.notifyOnVideoPublishedAfterScheduledUpdate(video)
} catch (err) {
- logger.error('Cannot update video', { err, ...lTags(videoOnly.uuid) })
+ logger.error('Cannot update video ' + videoOnly.uuid, { err, ...lTags(videoOnly.uuid) })
}
mutexReleaser()
diff --git a/server/core/lib/video-privacy.ts b/server/core/lib/video-privacy.ts
index 4577101dd2..f414182723 100644
--- a/server/core/lib/video-privacy.ts
+++ b/server/core/lib/video-privacy.ts
@@ -1,11 +1,13 @@
-import { move } from 'fs-extra/esm'
-import { join } from 'path'
-import { VideoPrivacy, VideoPrivacyType, FileStorage } from '@peertube/peertube-models'
-import { logger } from '@server/helpers/logger.js'
+import { FileStorage, VideoPrivacy, VideoPrivacyType } from '@peertube/peertube-models'
+import { logger, loggerTagsFactory } from '@server/helpers/logger.js'
import { DIRECTORIES } from '@server/initializers/constants.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'
+const lTags = loggerTagsFactory('video-privacy')
+
const validPrivacySet = new Set<VideoPrivacyType>([
VideoPrivacy.PRIVATE,
VideoPrivacy.INTERNAL,
@@ -58,11 +60,20 @@ async function moveFiles (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) {
if (file.storage === FileStorage.FILE_SYSTEM) {
await moveWebVideoFileOnFS(type, video, file)
} 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) {
await moveHLSFilesOnFS(type, video)
} else {
- await updateHLSFilesACL(hls)
+ try {
+ await updateHLSFilesACL(hls)
+ } catch (err) {
+ logger.error(objectStorageErrorMsg, { err, ...lTags('object-storage', video.uuid) })
+ }
}
}
}