Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

Can't Cancel Sync in Progress if Dropbox Unreachable #11

@steveshepard

Description

@steveshepard

Hi Jesse,

Found this one in the course of "pull the cable" testing.

If Dropbox is unreachable when you start a sync, FolderSyncPathOperation can't load metadata. The db client will eventually time out (~ 2 minutes, I think), but you can't cancel the sync before that time with cancelSyncInProgress because:

  • cancelSyncInProgress calls [folderSyncPathOperationOperationQueue cancelAllOperations]
  • -[FolderSyncPathOperation cancel] calls -[PathOperation cancel]
  • -[PathOperation cancel] simply returns without canceling if self.isExecuting is YES.
  • The only way self.isExecuting is NO is if a path operation calls finish:
  • Since the metadata isn't loaded yet, there are no path operations (except for the FolderSyncOperation) to call finish: so the cancel never completes.

I'm not sure why self.isExecuting is blocking the cancel (I suspect there are some path operations that need to complete), so I've worked around this specific case by setting isExecuting to NO in -[FolderSyncPathOperation cancel] as follows:

- (void)cancel {
    if (![NSThread isMainThread]) {
        [self performSelectorOnMainThread:@selector(cancel) withObject:nil waitUntilDone:NO];
        return;
    }

    [[[pathOperations copy] autorelease] makeObjectsPerformSelector:@selector(cancel)];
    needsCleanupSync = NO;
    updatedLastSyncHashOnFinish = NO;

    if (!loadedMetadata) {
        if (pathOperations.count == 0) {
            [self willChangeValueForKey:@"isExecuting"];
            isExecuting = NO;
            [self didChangeValueForKey:@"isExecuting"];
        }
        [super cancel];
    }
}

Since there are no path operations, the only thing to cancel is the metadata request, which will now be cancelled in [super cancel].

I reproduce this by disconnecting my wireless router from the cable modem.

-Steve

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions