From e0e7274339ea388c12dd47c2846e89adb8f60cc4 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 4 Feb 2022 22:03:22 -0800 Subject: [PATCH] HTTP Reader: Fix opening really tiny files Tiny files complete fetching within the scope of the open function, so the URL session task would have completed already. Now the function will accept the data, and allow reading it. Signed-off-by: Christopher Snowhill --- Plugins/HTTPSource/HTTPSource.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/HTTPSource/HTTPSource.m b/Plugins/HTTPSource/HTTPSource.m index c0014ba7e..a8bcc3c68 100644 --- a/Plugins/HTTPSource/HTTPSource.m +++ b/Plugins/HTTPSource/HTTPSource.m @@ -200,7 +200,7 @@ didCompleteWithError:(NSError *)error{ while (task && !didReceiveResponse) usleep(1000); - if (!task) return NO; + if (!task && !didReceiveResponse) return NO; return YES; } @@ -228,8 +228,10 @@ didCompleteWithError:(NSError *)error{ - (long)read:(void *)buffer amount:(long)amount { - if (didComplete) - return 0; + @synchronized (bufferedData) { + if (didComplete && ![bufferedData length]) + return 0; + } long totalRead = 0; long bytesBuffered = 0;