forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduledCleaner.swift
More file actions
27 lines (26 loc) · 968 Bytes
/
ScheduledCleaner.swift
File metadata and controls
27 lines (26 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import Foundation
public final class ScheduledCleaner {
public init() {
// occasionally cleanup workspaces.
Task { @ServiceActor in
while !Task.isCancelled {
try await Task.sleep(nanoseconds: 8 * 60 * 60 * 1_000_000_000)
for (url, workspace) in workspaces {
if workspace.isExpired {
workspaces[url] = nil
} else {
// cleanup chats for unused files
let filespaces = workspace.filespaces
for (url, filespace) in filespaces {
if filespace.isExpired {
WidgetDataSource.shared.cleanup(for: url)
}
}
// cleanup workspace
workspace.cleanUp()
}
}
}
}
}
}