From e5cbe7aa94b7c01feeab88cf24148358a4d85a89 Mon Sep 17 00:00:00 2001 From: Miltiadis Vasilakis Date: Sun, 7 Jul 2013 16:54:04 +0300 Subject: [PATCH 1/1] Retry failed sync service requests that may have an updated URL in the service catalog For requests that use a URL from the service catalog, if they return status code 401 or 404 or unknown, retry after you update the service catalog and the request URL. Update version. --- pithos-macos/PithosSyncDaemon.m | 42 ++++++++++++++-------------------- pithos-macos/pithos-macos-Info.plist | 4 ++-- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/pithos-macos/PithosSyncDaemon.m b/pithos-macos/PithosSyncDaemon.m index 937a48c..0619dce 100644 --- a/pithos-macos/PithosSyncDaemon.m +++ b/pithos-macos/PithosSyncDaemon.m @@ -409,32 +409,22 @@ } - (void)setPithos:(ASIPithos *)aPithos { - if (!pithos) { + if (!aPithos) { + return; + } else if (!pithos) { pithos = [ASIPithos pithos]; - pithos.authToken = [aPithos.authToken copy]; - pithos.authUser = [aPithos.authUser copy]; - pithos.ignoreSSLErrors = aPithos.ignoreSSLErrors; - pithos.tokensURL = [aPithos.tokensURL copy]; - pithos.storageURLPrefix = [aPithos.storageURLPrefix copy]; - pithos.publicURLPrefix = [aPithos.publicURLPrefix copy]; - pithos.userCatalogURL = [aPithos.userCatalogURL copy]; - } - if (aPithos && - (![aPithos.authUser isEqualToString:pithos.authUser] || - ![aPithos.authToken isEqualToString:pithos.authToken] || - ![aPithos.storageURLPrefix isEqual:pithos.storageURLPrefix])) { + } else if (![aPithos.tokensURL isEqualToString:pithos.tokensURL] || ![aPithos.authUser isEqualToString:pithos.authUser]) { + // If the authURL or the authUser actually changed, reset daemon and local state. [self resetDaemon]; - if (![aPithos.authUser isEqualToString:pithos.authUser] || - ![aPithos.storageURLPrefix isEqual:pithos.storageURLPrefix]) - [self resetLocalStateWithAll:YES]; - pithos.authToken = [aPithos.authToken copy]; - pithos.authUser = [aPithos.authUser copy]; - pithos.ignoreSSLErrors = aPithos.ignoreSSLErrors; - pithos.tokensURL = [aPithos.tokensURL copy]; - pithos.storageURLPrefix = [aPithos.storageURLPrefix copy]; - pithos.publicURLPrefix = [aPithos.publicURLPrefix copy]; - pithos.userCatalogURL = [aPithos.userCatalogURL copy]; + [self resetLocalStateWithAll:YES]; } + pithos.authToken = [aPithos.authToken copy]; + pithos.authUser = [aPithos.authUser copy]; + pithos.ignoreSSLErrors = aPithos.ignoreSSLErrors; + pithos.tokensURL = [aPithos.tokensURL copy]; + pithos.storageURLPrefix = [aPithos.storageURLPrefix copy]; + pithos.publicURLPrefix = [aPithos.publicURLPrefix copy]; + pithos.userCatalogURL = [aPithos.userCatalogURL copy]; } #pragma mark - @@ -1880,7 +1870,8 @@ // If the server listing fails, the sync should start over, so just retrying is enough NSUInteger retries = [[containerRequest.userInfo objectForKey:@"retries"] unsignedIntegerValue]; if (retries > 0) { - ASIPithosContainerRequest *newContainerRequest = (ASIPithosContainerRequest *)[PithosUtilities copyRequest:containerRequest]; + ASIPithosContainerRequest *newContainerRequest = (ASIPithosContainerRequest *)[PithosUtilities retryWithUpdatedURLRequest:containerRequest + andPithosAccountManager:pithosAccount]; [(NSMutableDictionary *)(newContainerRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"]; [networkQueue addOperation:[PithosUtilities prepareRequest:newContainerRequest priority:[[newContainerRequest.userInfo objectForKey:@"priority"] integerValue]]]; } else { @@ -2380,7 +2371,8 @@ } NSUInteger retries = [[request.userInfo objectForKey:@"retries"] unsignedIntegerValue]; if (retries > 0) { - ASIPithosRequest *newRequest = (ASIPithosRequest *)[PithosUtilities copyRequest:request]; + ASIPithosRequest *newRequest = (ASIPithosRequest *)[PithosUtilities retryWithUpdatedURLRequest:request + andPithosAccountManager:pithosAccount]; [(NSMutableDictionary *)(newRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"]; [networkQueue addOperation:[PithosUtilities prepareRequest:newRequest priority:[[newRequest.userInfo objectForKey:@"priority"] integerValue]]]; } else { diff --git a/pithos-macos/pithos-macos-Info.plist b/pithos-macos/pithos-macos-Info.plist index 81eb564..3fd0f7e 100644 --- a/pithos-macos/pithos-macos-Info.plist +++ b/pithos-macos/pithos-macos-Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.2.9 + 1.3 CFBundleSignature ???? CFBundleURLTypes @@ -32,7 +32,7 @@ CFBundleVersion - 20130319.1 + 20130707.0 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSMainNibFile -- 1.7.10.4