Bug fix for lost avatars on profile update

Following a profile update, we need to reupload the avatar. Currently
we're uploading the avatar by writing it to a temporary file and kicking
off an NSURLSessionUploadTask.

If Class A keys aren't available, we'd fail to complete the upload. This
would remove the user's avatar from their profile.
This commit is contained in:
Michelle Linington 2022-01-05 23:06:26 -08:00
parent f363ff4290
commit 378e58431f
4 changed files with 4 additions and 4 deletions

View File

@ -8,7 +8,7 @@ extension OWSSyncGroupsMessage {
@objc
public func buildPlainTextAttachmentFile(transaction: SDSAnyReadTransaction) -> URL? {
let fileUrl = OWSFileSystem.temporaryFileUrl()
let fileUrl = OWSFileSystem.temporaryFileUrl(isAvailableWhileDeviceLocked: true)
guard let outputStream = OutputStream(url: fileUrl, append: false) else {
owsFailDebug("Could not open outputStream.")
return nil

View File

@ -676,7 +676,7 @@ public extension OWSUpload {
let cdn0UrlSession = signalService.urlSessionForCdn(cdnNumber: 0)
return firstly { () -> Promise<HTTPResponse> in
let dataFileUrl = OWSFileSystem.temporaryFileUrl()
let dataFileUrl = OWSFileSystem.temporaryFileUrl(isAvailableWhileDeviceLocked: true)
try data.write(to: dataFileUrl)
let request = try cdn0UrlSession.buildRequest(uploadUrlPath, method: .post)

View File

@ -1311,7 +1311,7 @@ extension OWSURLSession {
textParts textPartsDictionary: OrderedDictionary<String, String>,
progress progressBlock: ProgressBlock? = nil) -> Promise<HTTPResponse> {
do {
let multipartBodyFileURL = OWSFileSystem.temporaryFileUrl()
let multipartBodyFileURL = OWSFileSystem.temporaryFileUrl(isAvailableWhileDeviceLocked: true)
let boundary = OWSMultipartBody.createMultipartFormBoundary()
// Order of form parts matters.
let textParts = textPartsDictionary.map { (key, value) in

View File

@ -106,7 +106,7 @@ public class AudioWaveformManager: NSObject {
// true and this path will no longer be hit.
if !asset.isReadable, audioPath.hasSuffix("m4a") {
let symlinkPath = OWSFileSystem.temporaryFilePath(fileExtension: "aac")
let symlinkPath = OWSFileSystem.temporaryFilePath(fileExtension: "aac", isAvailableWhileDeviceLocked: true)
do {
try FileManager.default.createSymbolicLink(atPath: symlinkPath,
withDestinationPath: audioPath)