按账号与相册隔离相机下载目录,并同步更新传输管道与测试。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -16,6 +16,7 @@ final class CameraTransferPipeline {
|
||||
private let cameraService: any CameraServiceProtocol
|
||||
private var uploadSink: (any CameraAssetUploadSink)?
|
||||
private var uploadEnabled = true
|
||||
private var downloadScope = CameraDownloadStorage.Scope(accountKey: "unscoped", albumID: 0)
|
||||
private var activeUploadAssetIDs: Set<String> = []
|
||||
private var autoUploadEligibleAssetIDs: Set<String> = []
|
||||
private var pendingDeferredNotifyTask: Task<Void, Never>?
|
||||
@ -36,10 +37,17 @@ final class CameraTransferPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
/// 配置上传 Sink 与是否自动上传。
|
||||
func configure(uploadSink: (any CameraAssetUploadSink)?, uploadEnabled: Bool) {
|
||||
/// 配置上传 Sink、自动上传开关与可选下载作用域。
|
||||
func configure(
|
||||
uploadSink: (any CameraAssetUploadSink)?,
|
||||
uploadEnabled: Bool,
|
||||
downloadScope: CameraDownloadStorage.Scope? = nil
|
||||
) {
|
||||
self.uploadSink = uploadSink
|
||||
self.uploadEnabled = uploadEnabled
|
||||
if let downloadScope {
|
||||
self.downloadScope = downloadScope
|
||||
}
|
||||
}
|
||||
|
||||
/// 启动相机连接。
|
||||
@ -243,10 +251,10 @@ final class CameraTransferPipeline {
|
||||
let localURL = try await cameraService.downloadAsset(resolvedAsset)
|
||||
let destination: URL
|
||||
|
||||
if CameraDownloadStorage.isInDownloadsDirectory(localURL) {
|
||||
if CameraDownloadStorage.isInOriginalsDirectory(localURL, scope: downloadScope) {
|
||||
destination = localURL
|
||||
} else {
|
||||
destination = CameraDownloadStorage.uniqueLocalURL(for: resolvedAsset.filename)
|
||||
destination = CameraDownloadStorage.uniqueLocalURL(for: resolvedAsset.filename, scope: downloadScope)
|
||||
if FileManager.default.fileExists(atPath: destination.path) {
|
||||
try FileManager.default.removeItem(at: destination)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user