aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-state.ts
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2021-11-09 11:05:35 +0100
committerGitHub <noreply@github.com>2021-11-09 11:05:35 +0100
commite1ab52d7ec7370a6f9f5937192d6003206af1ac0 (patch)
treeaecc8b696b0021e073fd205dd6e126fb4f178e8f /server/lib/video-state.ts
parentc49c366ac320fe5ac3dc08f5891fe5898c1b34e3 (diff)
downloadPeerTube-e1ab52d7ec7370a6f9f5937192d6003206af1ac0.tar.gz
PeerTube-e1ab52d7ec7370a6f9f5937192d6003206af1ac0.tar.zst
PeerTube-e1ab52d7ec7370a6f9f5937192d6003206af1ac0.zip
Add migrate-to-object-storage script (#4481)
* add migrate-to-object-storage-script closes #4467 * add migrate-to-unique-playlist-filenames script * fix(migrate-to-unique-playlist-filenames): update master/segments256 run updateMasterHLSPlaylist and updateSha256VODSegments after file rename. * Improve move to object storage scripts * PR remarks Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'server/lib/video-state.ts')
-rw-r--r--server/lib/video-state.ts38
1 files changed, 23 insertions, 15 deletions
diff --git a/server/lib/video-state.ts b/server/lib/video-state.ts
index 9352a67d1..d5bbbec43 100644
--- a/server/lib/video-state.ts
+++ b/server/lib/video-state.ts
@@ -57,10 +57,33 @@ function moveToNextState (video: MVideoUUID, isNewVideo = true) {
57 }) 57 })
58} 58}
59 59
60async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: boolean, transaction: Transaction) {
61 const videoJobInfo = await VideoJobInfoModel.load(video.id, transaction)
62 const pendingTranscode = videoJobInfo?.pendingTranscode || 0
63
64 // We want to wait all transcoding jobs before moving the video on an external storage
65 if (pendingTranscode !== 0) return false
66
67 await video.setNewState(VideoState.TO_MOVE_TO_EXTERNAL_STORAGE, isNewVideo, transaction)
68
69 logger.info('Creating external storage move job for video %s.', video.uuid, { tags: [ video.uuid ] })
70
71 try {
72 await addMoveToObjectStorageJob(video, isNewVideo)
73
74 return true
75 } catch (err) {
76 logger.error('Cannot add move to object storage job', { err })
77
78 return false
79 }
80}
81
60// --------------------------------------------------------------------------- 82// ---------------------------------------------------------------------------
61 83
62export { 84export {
63 buildNextVideoState, 85 buildNextVideoState,
86 moveToExternalStorageState,
64 moveToNextState 87 moveToNextState
65} 88}
66 89
@@ -82,18 +105,3 @@ async function moveToPublishedState (video: MVideoFullLight, isNewVideo: boolean
82 Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(video) 105 Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(video)
83 } 106 }
84} 107}
85
86async function moveToExternalStorageState (video: MVideoFullLight, isNewVideo: boolean, transaction: Transaction) {
87 const videoJobInfo = await VideoJobInfoModel.load(video.id, transaction)
88 const pendingTranscode = videoJobInfo?.pendingTranscode || 0
89
90 // We want to wait all transcoding jobs before moving the video on an external storage
91 if (pendingTranscode !== 0) return
92
93 await video.setNewState(VideoState.TO_MOVE_TO_EXTERNAL_STORAGE, isNewVideo, transaction)
94
95 logger.info('Creating external storage move job for video %s.', video.uuid, { tags: [ video.uuid ] })
96
97 addMoveToObjectStorageJob(video, isNewVideo)
98 .catch(err => logger.error('Cannot add move to object storage job', { err }))
99}