Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Only check for V1 orphaned uploads if there may be some
Browse files Browse the repository at this point in the history
  • Loading branch information
syoung-smallwisdom committed Sep 8, 2023
1 parent a2606e6 commit e987316
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ class BridgeFileUploadManager: SandboxFileManager, BridgeURLSessionDownloadDeleg

// Update the app manager's isUploading status. This needs to be done on the main queue.
self.runOnQueue(OperationQueue.main, sync: false) {
self.appManager.v1UploadsFinished = !uploading
self.appManager.isUploading = uploading
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import JsonModel
public let kPreviewStudyId = "xcode_preview"
public let kStudyIdKey = "studyId"
fileprivate let kUserSessionIdKey = "userSessionId"
fileprivate let kV1UploadsFinishedKey = "v1UploadsFinished"

open class UploadAppManager : ObservableObject {

Expand Down Expand Up @@ -39,6 +40,19 @@ open class UploadAppManager : ObservableObject {
Logger.logWriter?.setUserId(newValue)
}
}

/// Should the app manager check for V1 uploads? This will run the V1 manager at least once
/// on initial login to check for orphaned files, but after it finishes in-progress uploads
/// it will set the flag as `true` and will stop checking for v1 orphaned files.
var v1UploadsFinished: Bool {
get {
userSessionId != nil &&
sharedUserDefaults.bool(forKey: kV1UploadsFinishedKey)
}
set {
sharedUserDefaults.set(newValue, forKey: kV1UploadsFinishedKey)
}
}

/// The path to the pem file that is used to encrypt data being uploaded to Bridge.
///
Expand Down Expand Up @@ -187,7 +201,9 @@ open class UploadAppManager : ObservableObject {
// If we have a session token and it is different from the old one then check orphaned files.
if let newToken = session?.sessionToken, !newToken.isEmpty, newToken != oldToken {
Logger.log(severity: .info, message: "Session token updated: newToken='\(newToken)', oldToken='\(oldToken ?? "")'")
uploadManagerV1.onSessionTokenChanged()
if !v1UploadsFinished {
uploadManagerV1.onSessionTokenChanged()
}
}
}

Expand Down

0 comments on commit e987316

Please sign in to comment.