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
=== modified file 'Files/U1AutoUploadOperation.m'
--- Files/U1AutoUploadOperation.m 2011-12-05 22:53:05 +0000
+++ Files/U1AutoUploadOperation.m 2011-12-06 21:28:48 +0000
@@ -51,7 +51,14 @@
51 self.executing = YES;51 self.executing = YES;
52 [self didChangeValueForKey:@"isExecuting"];52 [self didChangeValueForKey:@"isExecuting"];
53 53
54 [self beginUpload];54 if ([self isCancelled])
55 {
56 [self finishExecuting];
57 }
58 else
59 {
60 [self beginUpload];
61 }
55}62}
5663
57- (void)dealloc64- (void)dealloc
5865
=== modified file 'Files/U1AutoUploadsManager.m'
--- Files/U1AutoUploadsManager.m 2011-12-06 19:44:22 +0000
+++ Files/U1AutoUploadsManager.m 2011-12-06 21:28:48 +0000
@@ -18,6 +18,7 @@
1818
19#import "Reachability.h"19#import "Reachability.h"
2020
21#import "U1AccountManager.h"
21#import "U1Asset.h"22#import "U1Asset.h"
22#import "U1AssetRepresenationDataProvider.h"23#import "U1AssetRepresenationDataProvider.h"
23#import "U1AutoUploadOperation.h"24#import "U1AutoUploadOperation.h"
@@ -75,6 +76,7 @@
75 dataRepository = [U1DataRepository sharedDataRepository];76 dataRepository = [U1DataRepository sharedDataRepository];
76 [defaultCenter addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];77 [defaultCenter addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
77 [defaultCenter addObserver:self selector:@selector(volumesFetched:) name:@"volumesFetched" object:nil];78 [defaultCenter addObserver:self selector:@selector(volumesFetched:) name:@"volumesFetched" object:nil];
79 [defaultCenter addObserver:self selector:@selector(didSignOut:) name:U1AccountManagerDidSignOut object:nil];
78 return self;80 return self;
79}81}
8082
@@ -176,6 +178,11 @@
176 // We received a list of volumes. If our upload folder is not among them, prime it.178 // We received a list of volumes. If our upload folder is not among them, prime it.
177}179}
178180
181- (void)didSignOut:(NSNotification*)notification;
182{
183 [self.autoUploadPreparationQueue cancelAllOperations];
184}
185
179- (void)fetchRemoteUploadFolderContents;186- (void)fetchRemoteUploadFolderContents;
180{187{
181 // fetch the remote upload folder contents, and stash the children objects somewhere locally.188 // fetch the remote upload folder contents, and stash the children objects somewhere locally.
182189
=== modified file 'Files/U1FilesClient.m'
--- Files/U1FilesClient.m 2011-12-03 02:58:25 +0000
+++ Files/U1FilesClient.m 2011-12-06 21:28:48 +0000
@@ -19,6 +19,7 @@
1919
20#import "Reachability.h"20#import "Reachability.h"
2121
22#import "U1AccountManager.h"
22#import "U1DataRepository.h"23#import "U1DataRepository.h"
23#import "U1FilesService.h"24#import "U1FilesService.h"
24#import "U1FileNode.h"25#import "U1FileNode.h"
@@ -65,12 +66,14 @@
65 [self.uploadsQueue setMaxConcurrentOperationCount:1];66 [self.uploadsQueue setMaxConcurrentOperationCount:1];
66 NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];67 NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
67 [defaultCenter addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];68 [defaultCenter addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
69 [defaultCenter addObserver:self selector:@selector(didSignOut:) name:U1AccountManagerDidSignOut object:nil];
68 return self;70 return self;
69}71}
7072
71- (void)dealloc;73- (void)dealloc;
72{74{
73 [[NSNotificationCenter defaultCenter] removeObserver:self];75 [[NSNotificationCenter defaultCenter] removeObserver:self];
76 [uploadsQueue cancelAllOperations];
74 [uploadsQueue release];77 [uploadsQueue release];
75 [super dealloc];78 [super dealloc];
76}79}
@@ -95,6 +98,11 @@
95 }98 }
96}99}
97100
101- (void)didSignOut:(NSNotification*)notification;
102{
103 [self.uploadsQueue cancelAllOperations];
104}
105
98- (id)accountInfoWithCompletionBlock:(void(^)(NSDictionary *accountInfo, NSError *error))completionBlock;106- (id)accountInfoWithCompletionBlock:(void(^)(NSDictionary *accountInfo, NSError *error))completionBlock;
99{107{
100 return [self.filesService accountInfoWithCompletionBlock:completionBlock];108 return [self.filesService accountInfoWithCompletionBlock:completionBlock];
101109
=== modified file 'Files/U1UploadOperation.m'
--- Files/U1UploadOperation.m 2011-12-05 19:51:30 +0000
+++ Files/U1UploadOperation.m 2011-12-06 21:28:48 +0000
@@ -71,6 +71,12 @@
7171
72- (void)beginUpload;72- (void)beginUpload;
73{73{
74 if ([self isCancelled])
75 {
76 [self finishExecuting];
77 return;
78 }
79
74 dispatch_async(dispatch_get_main_queue(), ^(void) {80 dispatch_async(dispatch_get_main_queue(), ^(void) {
7581
76 [self.fileInfo setUploadPercentage:0.0];82 [self.fileInfo setUploadPercentage:0.0];

Subscribers

People subscribed via source and target branches