@@ -263,23 +263,33 @@ func (p *PartUploader) GetStorage() storage.ReplayStorage {
263263const recordDirTimeFormat = "2006-01-02"
264264
265265func (p * PartUploader ) uploadToStorage (uploadPath string ) {
266- // check whether to use ENABLE_VIDEO_WORKER
267- if videoWorkerClient := NewWorkerClient (* config .GlobalConfig ); videoWorkerClient != nil {
268- taskCfg := videoworker.TaskConfig {
269- Width : p .Info .OptimalScreenWidth ,
270- Height : p .Info .OptimalScreenHeight ,
271- Bitrate : 1 ,
272- }
273- taskId , err := videoWorkerClient .CreateReplaySessionTask (p .SessionId , uploadPath , & taskCfg )
274- if err == nil {
275- logger .Infof ("Create replay session VideoWorker task success, task id: %s" , taskId )
276- if err = os .RemoveAll (p .RootPath ); err != nil {
277- logger .Errorf ("PartUploader %s remove root path %s error: %v" , p .SessionId , p .RootPath , err )
266+ if p .TermCfg == nil {
267+ // Without Core's storage configuration there is no safe fallback target.
268+ // Leave local replay files intact for a later recovery attempt.
269+ logger .Errorf ("PartUploader %s cannot upload replay without terminal config; retaining local files" , p .SessionId )
270+ return
271+ }
272+ // An environment switch alone must not route Community Edition recordings
273+ // to Video Worker. Core supplies the license state in terminal configuration.
274+ if shouldUseVideoWorker (config .GlobalConfig .EnableVideoWorker , p .TermCfg ) {
275+ videoWorkerClient := NewWorkerClient (* config .GlobalConfig )
276+ if videoWorkerClient != nil {
277+ taskCfg := videoworker.TaskConfig {
278+ Width : p .Info .OptimalScreenWidth ,
279+ Height : p .Info .OptimalScreenHeight ,
280+ Bitrate : 1 ,
278281 }
279- return
282+ taskId , err := videoWorkerClient .CreateReplaySessionTask (p .SessionId , uploadPath , & taskCfg )
283+ if err == nil {
284+ logger .Infof ("Create replay session VideoWorker task success, task id: %s" , taskId )
285+ if err = os .RemoveAll (p .RootPath ); err != nil {
286+ logger .Errorf ("PartUploader %s remove root path %s error: %v" , p .SessionId , p .RootPath , err )
287+ }
288+ return
289+ }
290+ // videoWorkerClient failed then try to use self storage to upload
291+ logger .Errorf ("Create replay session task error: %v, try to use self storage" , err )
280292 }
281- // videoWorkerClient failed then try to use self storage to upload
282- logger .Errorf ("Create replay session task error: %v, try to use self storage" , err )
283293 }
284294
285295 // 上传到存储
@@ -331,6 +341,10 @@ func (p *PartUploader) uploadToStorage(uploadPath string) {
331341
332342}
333343
344+ func shouldUseVideoWorker (enabled bool , terminalCfg * model.TerminalConfig ) bool {
345+ return enabled && terminalCfg != nil && terminalCfg .LicenseIsValid
346+ }
347+
334348func (p * PartUploader ) RecordLifecycleLog (event model.LifecycleEvent , logObj model.SessionLifecycleLog ) {
335349 if err := p .ApiClient .RecordSessionLifecycleLog (p .SessionId , event , logObj ); err != nil {
336350 logger .Errorf ("Record session %s lifecycle %s log err: %s" , p .SessionId , event , err )
0 commit comments