Build-Fix: KitColor statt RGBColor (Namenskonflikt mit QuickDraw), öffentlicher JerseySuggestion-Init, k-means vereinfacht, CGFloat→Double; Warnungen (NSLock in async, Captures)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
1 parent
9dcef7bd88
commit
3aa5bdef0e
6 files changed
+72
-40
No files matched your search
@@ -161,19 +161,29 @@ public final class ImmichClient: @unchecked Sendable {
|
||||
|
||||
/// Finds or creates an album and returns its id.
|
||||
public func albumId(named name: String) async throws -> String {
|
||||
lock.lock(); let cached = albumCache[name]; lock.unlock()
|
||||
if let cached { return cached }
|
||||
if let cached = cachedAlbum(name) { return cached }
|
||||
if let list = try await send(try request("albums")) as? [[String: Any]],
|
||||
let existing = list.first(where: { ($0["albumName"] as? String) == name }), let id = existing["id"] as? String {
|
||||
lock.lock(); albumCache[name] = id; lock.unlock()
|
||||
cacheAlbum(name, id)
|
||||
return id
|
||||
}
|
||||
guard let created = try await send(try request("albums", method: "POST", json: ["albumName": name])) as? [String: Any],
|
||||
let id = created["id"] as? String else { throw ImmichError.decoding }
|
||||
lock.lock(); albumCache[name] = id; lock.unlock()
|
||||
cacheAlbum(name, id)
|
||||
return id
|
||||
}
|
||||
|
||||
// NSLock must not be used directly in async functions → small synchronous helpers.
|
||||
private func cachedAlbum(_ name: String) -> String? {
|
||||
lock.lock(); defer { lock.unlock() }
|
||||
return albumCache[name]
|
||||
}
|
||||
|
||||
private func cacheAlbum(_ name: String, _ id: String) {
|
||||
lock.lock(); defer { lock.unlock() }
|
||||
albumCache[name] = id
|
||||
}
|
||||
|
||||
public func add(assetIds: [String], toAlbum albumId: String) async throws {
|
||||
_ = try await send(try request("albums/\(albumId)/assets", method: "PUT", json: ["ids": assetIds]))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user