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

Only check for V1 orphaned uploads if there may be some #230

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,16 @@ 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 { 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 +198,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
Loading