Browse files

handle exiting from waiting-to-quit status in the event that there we…

…re unsynced notes at the beginning of a check while index-listing was also in progress, but no collectors were dispatched as a result (and hence no didStopWithError: messages were received); this is probably because a note without metadata was deleted
  • Loading branch information...
1 parent b15cd29 commit 5122bc6c3880749c6edf7a0b8186dde59f6b40c1 Zachary Schneirov committed Feb 2, 2010
Showing with 11 additions and 15 deletions.
  1. +7 −10 NotationSyncServiceManager.m
  2. +4 −5 SimplenoteSession.m
@@ -220,9 +220,7 @@ - (void)makeNotesMatchList:(NSArray*)MDEntries fromSyncSession:(id <SyncServiceS
//show this only if there is no evidence of these notes ever being on the server (all remotely removed with none manually deleted)
if ([remotelyMissingNotes count] && [allNotes count] == ([remotelyMissingNotes count] + [locallyAddedNotes count])) {
if ([self handleSyncingWithAllMissingAndRemoteNoteCount:[remotelyAddedEntries count] fromSession:syncSession]) {
- //[delegate syncStatusShouldUpdateToShowProgress:NO error:NO];
- [syncSessionController queueStatusNotification];
- return;
+ goto ended;
@@ -242,7 +240,7 @@ - (void)makeNotesMatchList:(NSArray*)MDEntries fromSyncSession:(id <SyncServiceS
NSLocalizedString(@"Notes will be merged, omitting entries duplicated on the server.", nil),
NSLocalizedString(@"Add Notes", nil), NSLocalizedString(@"Turn Off Syncing", nil), nil) == NSAlertAlternateReturn) {
[syncSessionController disableService:serviceName];
- return;
+ goto ended;
} else {
//remember that we have to merge them for next time in case sync is cancelled; do not remember "automatic" merges
[notationPrefs setSyncShouldMerge:YES inCurrentAccountForService:serviceName];
@@ -295,18 +293,17 @@ - (void)makeNotesMatchList:(NSArray*)MDEntries fromSyncSession:(id <SyncServiceS
//for remotelyDeletedNotes, also remove syncMD from deletedNotes, but leave syncMD will be left in the undo-registered notes
[self removeSyncMDFromDeletedNotesInSet:[NSSet setWithArray:remotelyDeletedNotes] forService:serviceName];
- //set sync pulldown menu status here; we might not be continuing with the sync, in which case we wouldn't get a 'stop' message
+ //we might not be continuing with the sync, in which case we wouldn't get a 'stop' message
+ //so do things conditionally that otherwise might have been done when stopping
+ [syncSessionController performSelector:@selector(invokeUncommmitedWaitCallbackIfNecessaryReturningError:) withObject:nil afterDelay:0];
[syncSessionController queueStatusNotification];
- (void)syncSession:(id <SyncServiceSession>)syncSession didStopWithError:(NSString*)errString {
- //activate the "alert" icon of the pulldown menu; otherwise stop progress
- //[delegate syncStatusShouldUpdateToShowProgress:NO error:errString != nil];
- //[syncSessionController invokeUncommmitedWaitCallbackIfNecessaryReturningError:errString];
[syncSessionController performSelector:@selector(invokeUncommmitedWaitCallbackIfNecessaryReturningError:) withObject:errString afterDelay:0];
+ //if there was an error, the session would remember it and the sessioncontroller would report it when building the status menu
[syncSessionController queueStatusNotification];
@@ -320,12 +320,11 @@ - (BOOL)pushSyncServiceChanges {
//queue the note to be created; it doesn't have any metadata for this service
[notesToCreate addObject:aNote];
} else {
- //in this case we probably intended to _undo_ the creation of a note that doesn't yet have metadata
+ //in this case we probably intended to delete a note that didn't yet have metadata
//in which case the deleted note would have already taken the created one's place, and there's nothing more we need to do
NSLog(@"not creating an already-deleted note %@", aNote);
- //BUG: this presents a case in which we might have been waiting for unsynced notes to finish, but will now wait forever
- // should probably indicate in return value that no notes were pushed
- //BUG2: it would also be nice to wait for queued notes to finish
+ //this presents a case in which we might have been waiting for unsynced notes to finish, but will now wait forever
+ //thus this method indicates in the return value whether any notes were actually pushed
@@ -741,7 +740,7 @@ - (void)_modifyNotes:(NSArray*)notes withOperation:(SEL)opSEL {
[notesBeingModified addObjectsFromArray:currentlyIdleNotes];
if ([currentlyIdleNotes count]) {
- NSLog(@"%s(%@)", opSEL, currentlyIdleNotes);
+ //NSLog(@"%s(%@)", opSEL, currentlyIdleNotes);
//now actually start processing those notes
SimplenoteEntryModifier *modifier = [[SimplenoteEntryModifier alloc] initWithEntries:currentlyIdleNotes operation:opSEL authToken:authToken email:emailAddress];
SEL callback = (@selector(fetcherForCreatingNote:) == opSEL ? @selector(entryCreatorDidFinish:) :

0 comments on commit 5122bc6

Please sign in to comment.