Merge branch 'charlesmchen/profileReuploadRace'
This commit is contained in:
commit
4badc1748c
@ -9,7 +9,6 @@ public extension OWSProfileManager {
|
||||
|
||||
// The main entry point for updating the local profile. It will:
|
||||
//
|
||||
// * Update local state optimistically.
|
||||
// * Enqueue a service update.
|
||||
// * Attempt that service update.
|
||||
//
|
||||
@ -302,14 +301,7 @@ extension OWSProfileManager {
|
||||
let promise = firstly {
|
||||
writeProfileAvatarToDisk(attempt: attempt)
|
||||
}.then(on: DispatchQueue.global()) { () -> Promise<Void> in
|
||||
// Optimistically update local profile state.
|
||||
databaseStorage.write { transaction in
|
||||
self.updateLocalProfile(with: attempt,
|
||||
userProfileWriter: userProfileWriter,
|
||||
transaction: transaction)
|
||||
}
|
||||
|
||||
Logger.info("Versioned profile update.")
|
||||
Logger.info("Versioned profile update, avatarUrlPath: \(attempt.avatarUrlPath?.nilIfEmpty != nil), avatarFilename: \(attempt.avatarFilename?.nilIfEmpty != nil)")
|
||||
return updateProfileOnServiceVersioned(attempt: attempt)
|
||||
}.done(on: DispatchQueue.global()) { _ in
|
||||
self.databaseStorage.write { (transaction: SDSAnyWriteTransaction) -> Void in
|
||||
|
||||
@ -43,7 +43,7 @@ public class VersionedProfilesImpl: NSObject, VersionedProfilesSwift {
|
||||
profileAvatarData: Data?,
|
||||
unsavedRotatedProfileKey: OWSAES256Key?) -> Promise<VersionedProfileUpdate> {
|
||||
|
||||
return DispatchQueue.global().async(.promise) {
|
||||
firstly(on: .global()) {
|
||||
guard let localUuid = self.tsAccountManager.localUuid else {
|
||||
throw OWSAssertionError("Missing localUuid.")
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class VersionedProfilesImpl: NSObject, VersionedProfilesSwift {
|
||||
|
||||
let profileKey: OWSAES256Key = unsavedRotatedProfileKey ?? self.profileManager.localProfileKey()
|
||||
return (localUuid, profileKey)
|
||||
}.then(on: DispatchQueue.global()) { (localUuid: UUID, profileKey: OWSAES256Key) -> Promise<HTTPResponse> in
|
||||
}.then(on: .global()) { (localUuid: UUID, profileKey: OWSAES256Key) -> Promise<HTTPResponse> in
|
||||
let localProfileKey = try self.parseProfileKey(profileKey: profileKey)
|
||||
let zkgUuid = try localUuid.asZKGUuid()
|
||||
let commitment = try localProfileKey.getCommitment(uuid: zkgUuid)
|
||||
|
||||
@ -714,8 +714,9 @@ NSString *NSStringForUserProfileWriter(UserProfileWriter userProfileWriter)
|
||||
}
|
||||
}
|
||||
|
||||
BOOL isUpdatingDatabaseInstance = self != profile;
|
||||
if (shouldReupload && self.tsAccountManager.isPrimaryDevice
|
||||
&& CurrentAppContext().isMainApp) {
|
||||
&& CurrentAppContext().isMainApp && isUpdatingDatabaseInstance) {
|
||||
// shouldReuploadProtectedProfileName has side effects,
|
||||
// so only invoke it if shouldReupload is true.
|
||||
if (OWSUserProfile.shouldReuploadProtectedProfileName) {
|
||||
@ -744,7 +745,7 @@ NSString *NSStringForUserProfileWriter(UserProfileWriter userProfileWriter)
|
||||
@"%d), avatarUrlPathDidChange: %d (%d -> %d), "
|
||||
@"avatarFileNameDidChange: %d (%d -> %d), %@, %@.",
|
||||
profile.address,
|
||||
profile.address.isLocalAddress,
|
||||
[OWSUserProfile isLocalProfileAddress:profile.address],
|
||||
profileKeyDidChange,
|
||||
profileKeyBefore != nil,
|
||||
profile.profileKey != nil,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user