Merge lp:~threeve/ubuntuone-ios-files/logout-cleanup into lp:ubuntuone-ios-files

Proposed by Jason Foreman
Status: Merged
Approved by: Zachery Bir
Approved revision: 28
Merged at revision: 34
Proposed branch: lp:~threeve/ubuntuone-ios-files/logout-cleanup
Merge into: lp:ubuntuone-ios-files
Diff against target: 107 lines (+29/-1)
4 files modified
Files/U1AutoUploadOperation.m (+8/-1)
Files/U1AutoUploadsManager.m (+7/-0)
Files/U1FilesClient.m (+8/-0)
Files/U1UploadOperation.m (+6/-0)
To merge this branch: bzr merge lp:~threeve/ubuntuone-ios-files/logout-cleanup
Reviewer Review Type Date Requested Status
Zachery Bir Approve
Review via email: mp+84679@code.launchpad.net

Description of the change

Cancel pending uploads when signing out.

To post a comment you must log in.
Revision history for this message
Zachery Bir (urbanape) wrote :

woot.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Files/U1AutoUploadOperation.m'
2--- Files/U1AutoUploadOperation.m 2011-12-05 22:53:05 +0000
3+++ Files/U1AutoUploadOperation.m 2011-12-06 21:28:48 +0000
4@@ -51,7 +51,14 @@
5 self.executing = YES;
6 [self didChangeValueForKey:@"isExecuting"];
7
8- [self beginUpload];
9+ if ([self isCancelled])
10+ {
11+ [self finishExecuting];
12+ }
13+ else
14+ {
15+ [self beginUpload];
16+ }
17 }
18
19 - (void)dealloc
20
21=== modified file 'Files/U1AutoUploadsManager.m'
22--- Files/U1AutoUploadsManager.m 2011-12-06 19:44:22 +0000
23+++ Files/U1AutoUploadsManager.m 2011-12-06 21:28:48 +0000
24@@ -18,6 +18,7 @@
25
26 #import "Reachability.h"
27
28+#import "U1AccountManager.h"
29 #import "U1Asset.h"
30 #import "U1AssetRepresenationDataProvider.h"
31 #import "U1AutoUploadOperation.h"
32@@ -75,6 +76,7 @@
33 dataRepository = [U1DataRepository sharedDataRepository];
34 [defaultCenter addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
35 [defaultCenter addObserver:self selector:@selector(volumesFetched:) name:@"volumesFetched" object:nil];
36+ [defaultCenter addObserver:self selector:@selector(didSignOut:) name:U1AccountManagerDidSignOut object:nil];
37 return self;
38 }
39
40@@ -176,6 +178,11 @@
41 // We received a list of volumes. If our upload folder is not among them, prime it.
42 }
43
44+- (void)didSignOut:(NSNotification*)notification;
45+{
46+ [self.autoUploadPreparationQueue cancelAllOperations];
47+}
48+
49 - (void)fetchRemoteUploadFolderContents;
50 {
51 // fetch the remote upload folder contents, and stash the children objects somewhere locally.
52
53=== modified file 'Files/U1FilesClient.m'
54--- Files/U1FilesClient.m 2011-12-03 02:58:25 +0000
55+++ Files/U1FilesClient.m 2011-12-06 21:28:48 +0000
56@@ -19,6 +19,7 @@
57
58 #import "Reachability.h"
59
60+#import "U1AccountManager.h"
61 #import "U1DataRepository.h"
62 #import "U1FilesService.h"
63 #import "U1FileNode.h"
64@@ -65,12 +66,14 @@
65 [self.uploadsQueue setMaxConcurrentOperationCount:1];
66 NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
67 [defaultCenter addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
68+ [defaultCenter addObserver:self selector:@selector(didSignOut:) name:U1AccountManagerDidSignOut object:nil];
69 return self;
70 }
71
72 - (void)dealloc;
73 {
74 [[NSNotificationCenter defaultCenter] removeObserver:self];
75+ [uploadsQueue cancelAllOperations];
76 [uploadsQueue release];
77 [super dealloc];
78 }
79@@ -95,6 +98,11 @@
80 }
81 }
82
83+- (void)didSignOut:(NSNotification*)notification;
84+{
85+ [self.uploadsQueue cancelAllOperations];
86+}
87+
88 - (id)accountInfoWithCompletionBlock:(void(^)(NSDictionary *accountInfo, NSError *error))completionBlock;
89 {
90 return [self.filesService accountInfoWithCompletionBlock:completionBlock];
91
92=== modified file 'Files/U1UploadOperation.m'
93--- Files/U1UploadOperation.m 2011-12-05 19:51:30 +0000
94+++ Files/U1UploadOperation.m 2011-12-06 21:28:48 +0000
95@@ -71,6 +71,12 @@
96
97 - (void)beginUpload;
98 {
99+ if ([self isCancelled])
100+ {
101+ [self finishExecuting];
102+ return;
103+ }
104+
105 dispatch_async(dispatch_get_main_queue(), ^(void) {
106
107 [self.fileInfo setUploadPercentage:0.0];

Subscribers

People subscribed via source and target branches