[Libreoffice-commits] online.git: ios/Mobile
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Dec 19 11:39:30 UTC 2018
ios/Mobile/AppDelegate.mm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 3ec92f137e7119d2bfdc32c29e91cdd665e39dd6
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Dec 19 13:36:44 2018 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Dec 19 13:38:43 2018 +0200
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
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];
}
More information about the Libreoffice-commits
mailing list