Revision ca913781 pithos-macos/PithosSyncDaemon.m
b/pithos-macos/PithosSyncDaemon.m | ||
---|---|---|
73 | 73 |
@end |
74 | 74 |
|
75 | 75 |
@implementation PithosSyncDaemon |
76 |
@synthesize directoryPath, pithosAccount, containersDictionary, pithos;
|
|
76 |
@synthesize directoryPath, containersDictionary, pithos; |
|
77 | 77 |
@synthesize pithosContainers; |
78 | 78 |
@synthesize lastCompletedSync, remoteObjects, previousRemoteObjects, storedLocalObjectStates, currentLocalObjectStates; |
79 | 79 |
@synthesize pithosStateFilePath, tempDownloadsDirPath, tempTrashDirPath; |
... | ... | |
83 | 83 |
|
84 | 84 |
- (id)initWithDirectoryPath:(NSString *)aDirectoryPath |
85 | 85 |
pithosAccount:(PithosAccount *)aPithosAccount |
86 |
containersDictionary:(NSMutableDictionary *)aContainersDictionary
|
|
86 |
containersDictionary:(NSDictionary *)aContainersDictionary |
|
87 | 87 |
resetLocalState:(BOOL)resetLocalState { |
88 | 88 |
if ((self = [super init])) { |
89 | 89 |
directoryPath = [aDirectoryPath copy]; |
90 | 90 |
pithosAccount = [aPithosAccount retain]; |
91 |
containersDictionary = [aContainersDictionary retain];
|
|
91 |
containersDictionary = [aContainersDictionary copy];
|
|
92 | 92 |
self.pithos = pithosAccount.pithos; |
93 | 93 |
|
94 | 94 |
containersCount = [containersDictionary count]; |
95 | 95 |
self.pithosContainers = [NSMutableArray arrayWithCapacity:containersCount]; |
96 |
for (NSString *containerName in [containersDictionary allKeys]) {
|
|
96 |
for (NSString *containerName in containersDictionary) {
|
|
97 | 97 |
ASIPithosContainer *pithosContainer = [ASIPithosContainer container]; |
98 | 98 |
pithosContainer.name = containerName; |
99 | 99 |
[pithosContainers addObject:pithosContainer]; |
... | ... | |
172 | 172 |
// Remove containers that don't interest us anymore and save |
173 | 173 |
if (!storedLocalObjectStates) |
174 | 174 |
[self loadLocalState]; |
175 |
for (NSString *containerName in [storedLocalObjectStates allKeys]) {
|
|
175 |
for (NSString *containerName in storedLocalObjectStates) {
|
|
176 | 176 |
if (![containersDictionary objectForKey:containerName]) { |
177 | 177 |
[storedLocalObjectStates removeObjectForKey:containerName]; |
178 | 178 |
if (self.tempDownloadsDirPath) { |
... | ... | |
373 | 373 |
if (aContainersDictionary && ![aContainersDictionary isEqualToDictionary:containersDictionary]) { |
374 | 374 |
[self resetDaemon]; |
375 | 375 |
[containersDictionary release]; |
376 |
containersDictionary = [aContainersDictionary retain];
|
|
376 |
containersDictionary = [aContainersDictionary copy];
|
|
377 | 377 |
containersCount = [containersDictionary count]; |
378 | 378 |
self.pithosContainers = [NSMutableArray arrayWithCapacity:containersCount]; |
379 |
for (NSString *containerName in [containersDictionary allKeys]) {
|
|
379 |
for (NSString *containerName in aContainersDictionary) {
|
|
380 | 380 |
ASIPithosContainer *pithosContainer = [ASIPithosContainer container]; |
381 | 381 |
pithosContainer.name = containerName; |
382 | 382 |
[pithosContainers addObject:pithosContainer]; |
383 | 383 |
} |
384 | 384 |
[self resetLocalStateWithAll:NO]; |
385 |
}
|
|
385 |
} |
|
386 | 386 |
} |
387 | 387 |
|
388 | 388 |
- (void)setPithos:(ASIPithos *)aPithos { |
... | ... | |
711 | 711 |
NSFileManager *fileManager = [NSFileManager defaultManager]; |
712 | 712 |
BOOL isDirectory; |
713 | 713 |
NSError *error = nil; |
714 |
for (NSString *localFilePath in [currentLocalObjectStates allKeys]) {
|
|
714 |
for (NSString *localFilePath in currentLocalObjectStates) {
|
|
715 | 715 |
localState = [currentLocalObjectStates objectForKey:localFilePath]; |
716 | 716 |
if (!localState.isDirectory && [hash isEqualToString:localState.hash] && |
717 | 717 |
[fileManager fileExistsAtPath:localFilePath isDirectory:&isDirectory] && !isDirectory) { |
... | ... | |
1347 | 1347 |
self.currentLocalObjectStates = [NSMutableDictionary dictionary]; |
1348 | 1348 |
for (ASIPithosContainer *pithosContainer in pithosContainers) { |
1349 | 1349 |
NSString *containerDirectoryPath = [directoryPath stringByAppendingPathComponent:pithosContainer.name]; |
1350 |
NSMutableArray *containerExcludedDirectories = [containersDictionary objectForKey:pithosContainer.name];
|
|
1350 |
NSArray *containerExcludedDirectories = [containersDictionary objectForKey:pithosContainer.name]; |
|
1351 | 1351 |
BOOL containerExludeRootFiles = [containerExcludedDirectories containsObject:@""]; |
1352 | 1352 |
NSMutableDictionary *containerStoredLocalObjectStates = [storedLocalObjectStates objectForKey:pithosContainer.name]; |
1353 | 1353 |
NSDirectoryEnumerator *dirEnumerator = [fileManager enumeratorAtPath:containerDirectoryPath]; |
... | ... | |
1419 | 1419 |
|
1420 | 1420 |
// Add an empty stored state for legal new remote objects since last sync |
1421 | 1421 |
for (ASIPithosContainer *pithosContainer in pithosContainers) { |
1422 |
NSMutableArray *containerExcludedDirectories = [containersDictionary objectForKey:pithosContainer.name];
|
|
1422 |
NSArray *containerExcludedDirectories = [containersDictionary objectForKey:pithosContainer.name]; |
|
1423 | 1423 |
BOOL containerExludeRootFiles = [containerExcludedDirectories containsObject:@""]; |
1424 | 1424 |
NSMutableDictionary *containerStoredLocalObjectStates = [storedLocalObjectStates objectForKey:pithosContainer.name]; |
1425 | 1425 |
NSMutableDictionary *containerRemoteObjects = [remoteObjects objectForKey:pithosContainer.name]; |
... | ... | |
1471 | 1471 |
// These should be identified and skipped |
1472 | 1472 |
for (ASIPithosContainer *pithosContainer in pithosContainers) { |
1473 | 1473 |
NSString *containerDirectoryPath = [directoryPath stringByAppendingPathComponent:pithosContainer.name]; |
1474 |
NSMutableArray *containerExcludedDirectories = [containersDictionary objectForKey:pithosContainer.name];
|
|
1474 |
NSArray *containerExcludedDirectories = [containersDictionary objectForKey:pithosContainer.name]; |
|
1475 | 1475 |
BOOL containerExludeRootFiles = [containerExcludedDirectories containsObject:@""]; |
1476 | 1476 |
NSMutableDictionary *containerStoredLocalObjectStates = [storedLocalObjectStates objectForKey:pithosContainer.name]; |
1477 | 1477 |
NSMutableDictionary *containerRemoteObjects = [remoteObjects objectForKey:pithosContainer.name]; |
Also available in: Unified diff