@@ -247,14 +247,15 @@ public async Task<UploadResult> StashNextChunkAsync(int chunkSize, CancellationT
247247 // Possible error: code=stashfailed, info=Invalid chunk offset
248248 // We will retry from the server-expected offset.
249249 var err = jresult [ "error" ] ;
250- if ( err != null && ( string ) err [ "code" ] == "stashfailed" && err [ "offset" ] != null )
250+ if ( err != null && ( string ? ) err [ "code" ] == "stashfailed" && err [ "offset" ] != null )
251251 {
252+ var offset = ( int ) err [ "offset" ] ! ;
252253 Site . Logger . LogWarning ( "Server reported: {Message}. Will retry from offset {Offset}." ,
253- ( string ) err [ "info" ] , ( int ) err [ " offset" ] ) ;
254- UploadedSize = ( int ) err [ " offset" ] ;
254+ ( string ? ) err [ "info" ] , offset ) ;
255+ UploadedSize = offset ;
255256 goto RETRY ;
256257 }
257- result = jresult [ "upload" ] . Deserialize < UploadResult > ( MediaWikiHelper . WikiJsonSerializerOptions ) ;
258+ result = jresult [ "upload" ] . Deserialize < UploadResult > ( MediaWikiHelper . WikiJsonSerializerOptions ) ! ;
258259 // Ignore warnings, as long as we have filekey to continue the upload.
259260 if ( result . FileKey == null )
260261 {
@@ -305,18 +306,15 @@ public override string ToString()
305306 private class ChunkedUploadResponseParser : MediaWikiJsonResponseParser
306307 {
307308
308- public static new readonly ChunkedUploadResponseParser Default = new ChunkedUploadResponseParser ( ) ;
309+ public static new readonly ChunkedUploadResponseParser Default = new ( ) ;
309310
310311 /// <inheritdoc />
311- protected override void OnApiError ( string errorCode , string errorMessage , JsonNode errorNode , JsonNode responseNode ,
312+ protected override void OnApiError ( string ? errorCode , string ? errorMessage , JsonNode errorNode , JsonNode responseNode ,
312313 WikiResponseParsingContext context )
313314 {
314315 // Possible error: code=stashfailed, info=Invalid chunk offset, offset=xxxx
315- // We will try to recover.
316- if ( errorCode == "stashfailed" && errorNode [ "offset" ] != null )
317- {
318- return ;
319- }
316+ // We will try to recover from the caller-side.
317+ if ( errorCode == "stashfailed" && errorNode [ "offset" ] != null ) return ;
320318 base . OnApiError ( errorCode , errorMessage , errorNode , responseNode , context ) ;
321319 }
322320
0 commit comments