@@ -717,24 +717,26 @@ public static byte[] DevicesTask(string[] hosts, bool dns, bool wmi, bool ldap,
717717 }
718718 }
719719
720- if ( task . cancellationToken . IsCancellationRequested ) {
721- KeepAlive . Broadcast ( "{\" action\" :\" abort-fetch\" ,\" type\" :\" devices\" }"u8 . ToArray ( ) , "/fetch/status" ) ;
722- Logger . Action ( origin , "Devices fetch task aborted" ) ;
720+ if ( task is not null ) {
721+ if ( task . cancellationToken . IsCancellationRequested ) {
722+ KeepAlive . Broadcast ( "{\" action\" :\" abort-fetch\" ,\" type\" :\" devices\" }"u8 . ToArray ( ) , "/fetch/status" ) ;
723+ Logger . Action ( origin , "Devices fetch task aborted" ) ;
723724
724- task ? . Dispose ( ) ;
725- task = null ;
726- return ;
727- }
725+ task ? . Dispose ( ) ;
726+ task = null ;
727+ return ;
728+ }
728729
729- result = new Result ( ) {
730- name = task . name ,
731- type = Type . devices ,
732- started = task . started ,
733- finished = DateTime . UtcNow . Ticks ,
734- dataset = dataset ,
735- successful = task . CompletedSteps ,
736- unsuccessful = task . TotalSteps - task . CompletedSteps ,
737- } ;
730+ result = new Result ( ) {
731+ name = task . name ,
732+ type = Type . devices ,
733+ started = task . started ,
734+ finished = DateTime . UtcNow . Ticks ,
735+ dataset = dataset ,
736+ successful = task . CompletedSteps ,
737+ unsuccessful = task . TotalSteps - task . CompletedSteps ,
738+ } ;
739+ }
738740
739741 KeepAlive . Broadcast ( $ "{{\" action\" :\" finish-fetch\" ,\" type\" :\" devices\" ,\" task\" :{ Encoding . UTF8 . GetString ( Status ( ) ) } }}", "/fetch/status" ) ;
740742 Logger . Action ( origin , "Fetch task finished" ) ;
0 commit comments