@@ -67,7 +67,7 @@ interface BitrateState {
6767 analyzeStream : ( path : string , streamIndex : number ) => Promise < void > ;
6868 analyzeOverall : ( path : string , fileHash ?: string ) => Promise < void > ;
6969 forceAnalyze : ( path : string ) => Promise < void > ;
70- cancelAnalysis : ( ) => Promise < void > ;
70+ cancelAnalysis : ( path ?: string ) => Promise < void > ;
7171 cancelAllJobs : ( ) => Promise < void > ;
7272 setAnalysisMode : ( mode : "overall" | "per-stream" ) => void ;
7373 setSelectedStreamIndex : ( index : number | null ) => void ;
@@ -260,21 +260,26 @@ export const useBitrateStore = create<BitrateState>((set, get) => ({
260260 }
261261 } ,
262262
263- cancelAnalysis : async ( ) => {
263+ cancelAnalysis : async ( path ?: string ) => {
264264 const { currentJobPath } = get ( ) ;
265- if ( ! currentJobPath ) {
265+ const targetPath = path || currentJobPath ;
266+
267+ if ( ! targetPath ) {
266268 console . log ( "[BitrateStore] No analysis to cancel" ) ;
267269 return ;
268270 }
269271
270- console . log ( `[BitrateStore] Cancelling analysis for: ${ currentJobPath } ` ) ;
272+ console . log ( `[BitrateStore] Cancelling analysis for: ${ targetPath } ` ) ;
271273 try {
272274 const cancelled = await invoke < boolean > ( "cancel_bitrate_analysis" , {
273- path : currentJobPath ,
275+ path : targetPath ,
274276 } ) ;
275277 if ( cancelled ) {
276278 console . log ( "[BitrateStore] Analysis cancelled successfully" ) ;
277- set ( { loading : false , currentJobPath : null } ) ;
279+ // Only clear currentJobPath if we cancelled the current job
280+ if ( targetPath === currentJobPath ) {
281+ set ( { loading : false , currentJobPath : null } ) ;
282+ }
278283 } else {
279284 console . log ( "[BitrateStore] No active job found to cancel" ) ;
280285 }
0 commit comments