ios/Mobile/AppDelegate.mm |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 7257e9ff317180d27115707a657840d289bec3ea
Author:     Tor Lillqvist <[email protected]>
AuthorDate: Wed Dec 19 13:36:44 2018 +0200
Commit:     Andras Timar <[email protected]>
CommitDate: Mon Mar 4 15:48:06 2019 +0100

    Be less fragile in case of missing resources when downloading templates
    
    It is not enough ot look at the NSError* parameter. Need to check the
    HTTP status code, too.
    
    Change-Id: I8db146c77626d4080ef6606999d27e6bb845876c
    Reviewed-on: https://gerrit.libreoffice.org/68328
    Reviewed-by: Andras Timar <[email protected]>
    Tested-by: Andras Timar <[email protected]>

diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm
index eadcda6a1..787a8a140 100644
--- a/ios/Mobile/AppDelegate.mm
+++ b/ios/Mobile/AppDelegate.mm
@@ -32,7 +32,7 @@ LibreOfficeKit *lo_kit;
 static void download(NSURL *source, NSURL *destination) {
     [[[NSURLSession sharedSession] downloadTaskWithURL:source
                                      completionHandler:^(NSURL *location, 
NSURLResponse *response, NSError *error) {
-                if (error == nil  && [(NSHTTPURLResponse*)response statusCode] 
== 200) {
+                if (error == nil && [response isKindOfClass:[NSHTTPURLResponse 
class]] && [(NSHTTPURLResponse*)response statusCode] == 200) {
                     NSError *error = nil;
                     NSURL *resultingItem = nil;
                     if ([[NSFileManager defaultManager] 
replaceItemAtURL:destination
@@ -114,7 +114,7 @@ static void updateTemplates(NSData *data, NSURLResponse 
*response)
                 [req setHTTPMethod:@"HEAD"];
                 [[[NSURLSession sharedSession] dataTaskWithRequest:req
                                                  completionHandler:^(NSData 
*data, NSURLResponse *response, NSError *error) {
-                            if (error == nil && [(NSHTTPURLResponse*)response 
statusCode] == 200) {
+                            if (error == nil && [response 
isKindOfClass:[NSHTTPURLResponse class]] && [(NSHTTPURLResponse*)response 
statusCode] == 200) {
                                 NSString *lastModified = 
[[(NSHTTPURLResponse*)response allHeaderFields] objectForKey:@"Last-Modified"];
                                 NSDateFormatter *df = [[NSDateFormatter alloc] 
init];
                                 df.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss z";
@@ -178,7 +178,7 @@ static void updateTemplates(NSData *data, NSURLResponse 
*response)
         if (url != nil) {
             [[[NSURLSession sharedSession] dataTaskWithURL:url
                                          completionHandler:^(NSData *data, 
NSURLResponse *response, NSError *error) {
-                        if (error == nil)
+                        if (error == nil && [response 
isKindOfClass:[NSHTTPURLResponse class]] && [(NSHTTPURLResponse*)response 
statusCode] == 200)
                             updateTemplates(data, response);
                     }] resume];
         }
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to