@@ -8338,6 +8338,12 @@ func (s *Service) executeExternalProgram(ctx context.Context, instanceID int, to
83388338 return
83398339 }
83408340
8341+ if ctx == nil {
8342+ ctx = context .Background ()
8343+ } else {
8344+ ctx = context .WithoutCancel (ctx )
8345+ }
8346+
83418347 // Get current settings to check if external program is configured
83428348 settings , err := s .GetAutomationSettings (ctx )
83438349 if err != nil {
@@ -8354,7 +8360,7 @@ func (s *Service) executeExternalProgram(ctx context.Context, instanceID int, to
83548360 // Execute in a separate goroutine to avoid blocking the cross-seed operation
83558361 go func () {
83568362 // Get torrent data from sync manager
8357- targetTorrent , found , err := s .syncManager .HasTorrentByAnyHash (context . Background () , instanceID , []string {torrentHash })
8363+ targetTorrent , found , err := s .syncManager .HasTorrentByAnyHash (ctx , instanceID , []string {torrentHash })
83588364 if err != nil {
83598365 log .Error ().Err (err ).Int ("instanceId" , instanceID ).Str ("torrentHash" , torrentHash ).Msg ("Failed to get torrent for external program execution" )
83608366 return
@@ -8372,8 +8378,7 @@ func (s *Service) executeExternalProgram(ctx context.Context, instanceID int, to
83728378 Msg ("Executing external program for cross-seed injection" )
83738379
83748380 // Execute using the shared external programs service
8375- execCtx := context .WithoutCancel (ctx )
8376- result := s .externalProgramService .Execute (execCtx , externalprograms.ExecuteRequest {
8381+ result := s .externalProgramService .Execute (ctx , externalprograms.ExecuteRequest {
83778382 ProgramID : programID ,
83788383 Torrent : targetTorrent ,
83798384 InstanceID : instanceID ,
0 commit comments