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

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

Open
steveshepard opened this issue Jul 25, 2011 · 0 comments
Open

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

steveshepard opened this issue Jul 25, 2011 · 0 comments

Comments

@steveshepard
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant