Rework thread safety in profile manager.

pull/1/head
Matthew Chen 8 years ago
parent 911c4d380b
commit ee300590e3

@ -845,7 +845,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
NSString *fileName = [[NSUUID UUID].UUIDString stringByAppendingPathExtension:@"jpg"]; NSString *fileName = [[NSUUID UUID].UUIDString stringByAppendingPathExtension:@"jpg"];
NSString *filePath = [self.profileAvatarsDirPath stringByAppendingPathComponent:fileName]; NSString *filePath = [self.profileAvatarsDirPath stringByAppendingPathComponent:fileName];
@synchronized(self) @synchronized(self.currentAvatarDownloads)
{ {
if ([self.currentAvatarDownloads containsObject:userProfile.recipientId]) { if ([self.currentAvatarDownloads containsObject:userProfile.recipientId]) {
// Download already in flight; ignore. // Download already in flight; ignore.
@ -871,7 +871,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
} }
} }
@synchronized(self) @synchronized(self.currentAvatarDownloads)
{ {
[self.currentAvatarDownloads removeObject:userProfile.recipientId]; [self.currentAvatarDownloads removeObject:userProfile.recipientId];
} }
@ -1153,7 +1153,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
} }
UIImage *_Nullable image = nil; UIImage *_Nullable image = nil;
@synchronized(self) @synchronized(self.profileAvatarImageCache)
{ {
image = [self.profileAvatarImageCache objectForKey:filename]; image = [self.profileAvatarImageCache objectForKey:filename];
} }
@ -1175,7 +1175,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
OWSAssert(filename.length > 0); OWSAssert(filename.length > 0);
OWSAssert(image); OWSAssert(image);
@synchronized(self) @synchronized(self.profileAvatarImageCache)
{ {
if (image) { if (image) {
[self.profileAvatarImageCache setObject:image forKey:filename]; [self.profileAvatarImageCache setObject:image forKey:filename];

Loading…
Cancel
Save