Skip to content

Commit d0e0c78

Browse files
author
mklepp
committed
Explain the synch algorithm in comments
1 parent 4b3ca4e commit d0e0c78

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

OwnCloud Notes/AppDelegate.m

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,22 @@ - (void) insertNoteSorted:(NSDictionary*) note
149149
[self insertObject:note inNotesAtIndex:newIndex];
150150
}
151151

152-
- (void)updateData:(NSNotification *)note
152+
/**
153+
A brief outline of the synch algorithm:
154+
155+
Prerequesites:
156+
strict serial working queue (no simultaneous requests)
157+
158+
workflow:
159+
-) cancel all pending requests (prevents multiple creation requests)
160+
-) if there are cached new notes (created on device, but not on server), queue their requests
161+
-) if there are cached updated notes (updated on device, but not on server), queue their requests
162+
-) if there are cached deleted notes (deleted on device, but not on server), queue their requests
163+
-) the notification param for the updateData method can contain a new created, updated or deleted note
164+
-) if the notification param contains a note, cache them according to their status and enqueue the corresponding request
165+
166+
**/
167+
- (void)updateData:(NSNotification *)notification
153168
{
154169
NSString* serverUrlString = [NSString stringWithFormat:@"%@%@", [[NSUserDefaults standardUserDefaults] valueForKey:kNotesServerURL], kServerPath];
155170

@@ -191,7 +206,7 @@ - (void)updateData:(NSNotification *)note
191206
lastOperation = newOperation;
192207
}
193208

194-
NSDictionary *theData = [note userInfo];
209+
NSDictionary *theData = [notification userInfo];
195210
if (theData != nil) {
196211

197212
NSDictionary* deletedNote = [theData valueForKey:kNotesNotificationDeleteItem];

0 commit comments

Comments
 (0)