按账号与相册隔离相机下载目录,并同步更新传输管道与测试。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-30 15:55:54 +08:00
parent 660852ffad
commit 5f7ef24683
14 changed files with 382 additions and 163 deletions

View File

@ -443,6 +443,7 @@ final class WiredCameraTransferViewModel: ObservableObject {
private let pipeline: CameraTransferPipeline
private var photoStore: WiredTransferPhotoStore?
private var userIDProvider: (() -> String)?
private var downloadScope: CameraDownloadStorage.Scope?
private var sessionNewPhotoIDs: Set<String> = []
private var persistedRecordsByID: [String: WiredTransferPhotoRecord] = [:]
private var lastAppliedPipelineSignatures: [String: PipelineTaskSignature] = [:]
@ -477,9 +478,16 @@ final class WiredCameraTransferViewModel: ObservableObject {
scenicID: Int,
accountContext: AccountContext
) async {
let accountCachePrefix = accountContext.accountCachePrefix ?? "guest_"
let currentDownloadScope = CameraDownloadStorage.Scope(
accountKey: accountCachePrefix,
albumID: context.albumId
)
downloadScope = currentDownloadScope
if photoStore == nil {
photoStore = WiredTransferPhotoStore(
accountPrefixProvider: { accountContext.accountCachePrefix ?? "guest_" },
accountPrefixProvider: { accountCachePrefix },
userIDProvider: { accountContext.profile?.userId ?? "" }
)
userIDProvider = { accountContext.profile?.userId ?? "" }
@ -494,7 +502,7 @@ final class WiredCameraTransferViewModel: ObservableObject {
scenicID: scenicID
)
let autoUpload = transferModeOption == Self.modeLiveCapture
pipeline.configure(uploadSink: uploader, uploadEnabled: autoUpload)
pipeline.configure(uploadSink: uploader, uploadEnabled: autoUpload, downloadScope: currentDownloadScope)
refreshDeviceStorageInfo()
loadPersistedPhotos()
await pipeline.connect()
@ -555,7 +563,7 @@ final class WiredCameraTransferViewModel: ObservableObject {
albumID: context.albumId,
scenicID: scenicID
)
pipeline.configure(uploadSink: uploader, uploadEnabled: autoUpload)
pipeline.configure(uploadSink: uploader, uploadEnabled: autoUpload, downloadScope: downloadScope)
}
///
@ -784,7 +792,7 @@ final class WiredCameraTransferViewModel: ObservableObject {
albumID: context.albumId,
scenicID: scenicID
)
pipeline.configure(uploadSink: uploader, uploadEnabled: true)
pipeline.configure(uploadSink: uploader, uploadEnabled: true, downloadScope: downloadScope)
}
private func persistedRecord(for photoID: String) -> WiredTransferPhotoRecord? {
@ -979,9 +987,14 @@ final class WiredCameraTransferViewModel: ObservableObject {
)
var thumbnailPath = existingRecord?.thumbnailPath ?? ""
if thumbnailPath.isEmpty,
let downloadScope,
let localURL,
status != .transferring,
let generatedPath = await CameraThumbnailGenerator.generateThumbnail(for: localURL, assetID: task.assetID) {
let generatedPath = await CameraThumbnailGenerator.generateThumbnail(
for: localURL,
assetID: task.assetID,
scope: downloadScope
) {
thumbnailPath = generatedPath
}
let thumbnailURL = thumbnailURLString(thumbnailPath: thumbnailPath, remoteURL: task.remoteURL ?? existingRecord?.remoteURL ?? "")