Skip to content

Commit 4207621

Browse files
- OCResourceRequest: add property .retryIfNotFound to explicitly tell the resource manager not to retry if the resource couldn't be found (#168)
- OCAppProviderApp/OCAppProviderFileType: use OCResourceRequest.retryIfNotFound to prevent infinite retry loops - OCResourceManager: add support for OCResourceRequest.retryIfNotFound
1 parent bf541c4 commit 4207621

5 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎ownCloudSDK/App Providers/OCAppProviderApp.m‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ - (OCResourceRequest *)iconResourceRequest
7676
if ((_iconResourceRequest == nil) && (_iconURL != nil))
7777
{
7878
_iconResourceRequest = [OCResourceRequestURLItem requestURLItem:_iconURL identifier:nil version:OCResourceRequestURLItem.daySpecificVersion structureDescription:@"icon" waitForConnectivity:YES changeHandler:nil];
79+
_iconResourceRequest.retryIfNotFound = NO;
7980
}
8081

8182
return (_iconResourceRequest);

‎ownCloudSDK/App Providers/OCAppProviderFileType.m‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ - (OCResourceRequest *)iconResourceRequest
3333
if ((_iconResourceRequest == nil) && (_iconURL != nil))
3434
{
3535
_iconResourceRequest = [OCResourceRequestURLItem requestURLItem:_iconURL identifier:nil version:OCResourceRequestURLItem.weekSpecificVersion structureDescription:@"icon" waitForConnectivity:YES changeHandler:nil];
36+
_iconResourceRequest.retryIfNotFound = NO;
3637
}
3738

3839
return (_iconResourceRequest);

‎ownCloudSDK/Core/Resources/Manager/OCResourceManager.m‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,15 +457,15 @@ - (void)_handleError:(nullable NSError *)error resource:(nullable OCResource *)r
457457
{
458458
// Resource is not available yet (f.ex. still processed by the server):
459459
// - log, but don't try again because resource could remain in processing for a loooong time
460-
// - handle as if resoruce does not exist
460+
// - handle as if resource does not exist
461461
OCTLogDebug(@[@"ResMan"], @"Handling source %@ returned resource=%@ error=%@ (!! remote resource processing - will not retry !!) as OCErrorResourceDoesNotExist", source.identifier, resource, error);
462462

463463
error = OCErrorFromError(OCErrorResourceDoesNotExist, error);
464464
}
465465

466466
if ([error isOCErrorWithCode:OCErrorResourceDoesNotExist])
467467
{
468-
// Resource does not exist anymore: delete from cache + restart job
468+
// Resource does not exist anymore: delete from cache + restart job (if .retryOnNotFound is enabled)
469469
__weak OCResourceManager *weakSelf = self;
470470
[self removeResourceOfType:job.primaryRequest.type identifier:job.primaryRequest.identifier completionHandler:^(NSError * _Nullable error) {
471471
OCResourceManager *strongSelf = weakSelf;
@@ -484,10 +484,13 @@ - (void)_handleError:(nullable NSError *)error resource:(nullable OCResource *)r
484484
}
485485

486486
// Restart job
487-
job.state = OCResourceManagerJobStateNew;
488-
job.sourcesCursorPosition = nil;
487+
if (job.primaryRequest.retryIfNotFound)
488+
{
489+
job.state = OCResourceManagerJobStateNew;
490+
job.sourcesCursorPosition = nil;
489491

490-
[strongSelf setNeedsScheduling];
492+
[strongSelf setNeedsScheduling];
493+
}
491494
});
492495
}
493496
}];

‎ownCloudSDK/Core/Resources/Request/OCResourceRequest.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ typedef NSString* OCResourceRequestGroupIdentifier;
7070
@property(readonly) CGSize maxPixelSize; //!< Computed from maxPointSize and scale
7171

7272
@property(assign) BOOL waitForConnectivity; //!< Sources that send requests to servers should wait for connectivity
73+
@property(assign) BOOL retryIfNotFound; //!< Sources that send requests to servers should retry even if the resource has not been found on the server
7374

7475
@property(assign,nonatomic) BOOL cancelled;
7576
@property(readonly) BOOL ended;

‎ownCloudSDK/Core/Resources/Request/OCResourceRequest.m‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ - (instancetype)init
2929
if ((self = [super init]) != nil)
3030
{
3131
_minimumQuality = OCResourceQualityFallback;
32+
_retryIfNotFound = YES;
3233
}
3334

3435
return (self);

0 commit comments

Comments
 (0)