Session Cache Implementation
Nucleic-Session: B2346642-3353-4BD5-9DE2-A8B77BD66C98 Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -68,7 +68,7 @@ enum SessionCache {
|
|||||||
guard let root, let url = summariesURL, let dir = transcriptsDir else { return }
|
guard let root, let url = summariesURL, let dir = transcriptsDir else { return }
|
||||||
try? FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)
|
try? FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)
|
||||||
let kept = Array(summaries.sorted { $0.updatedAt > $1.updatedAt }.prefix(sessionLimit))
|
let kept = Array(summaries.sorted { $0.updatedAt > $1.updatedAt }.prefix(sessionLimit))
|
||||||
if let data = try? encoder.encode(kept) { try? data.write(to: url, options: .atomic) }
|
if let data = try? JSONEncoder().encode(kept) { try? data.write(to: url, options: .atomic) }
|
||||||
// Drop transcript files for sessions that fell out of the recent set.
|
// Drop transcript files for sessions that fell out of the recent set.
|
||||||
let keep = Set(kept.map(transcriptFileName))
|
let keep = Set(kept.map(transcriptFileName))
|
||||||
if let files = try? FileManager.default.contentsOfDirectory(
|
if let files = try? FileManager.default.contentsOfDirectory(
|
||||||
|
|||||||
Reference in New Issue
Block a user