File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . Diagnostics ;
34using System . Globalization ;
45using System . Text ;
56using System . Threading ;
@@ -914,6 +915,8 @@ public void RequestWrite(byte[] handle,
914915 AutoResetEvent wait ,
915916 Action < SftpStatusResponse > writeCompleted = null )
916917 {
918+ Debug . Assert ( ( wait is null ) != ( writeCompleted is null ) , "Should have one parameter or the other." ) ;
919+
917920 SshException exception = null ;
918921
919922 var request = new SftpWriteRequest ( ProtocolVersion ,
@@ -925,22 +928,27 @@ public void RequestWrite(byte[] handle,
925928 length ,
926929 response =>
927930 {
928- writeCompleted ? . Invoke ( response ) ;
929-
930- exception = GetSftpException ( response ) ;
931- wait ? . SetIgnoringObjectDisposed ( ) ;
931+ if ( writeCompleted is not null )
932+ {
933+ writeCompleted . Invoke ( response ) ;
934+ }
935+ else
936+ {
937+ exception = GetSftpException ( response ) ;
938+ wait . SetIgnoringObjectDisposed ( ) ;
939+ }
932940 } ) ;
933941
934942 SendRequest ( request ) ;
935943
936944 if ( wait is not null )
937945 {
938946 WaitOnHandle ( wait , OperationTimeout ) ;
939- }
940947
941- if ( exception is not null )
942- {
943- throw exception ;
948+ if ( exception is not null )
949+ {
950+ throw exception ;
951+ }
944952 }
945953 }
946954
You can’t perform that action at this time.
0 commit comments