Improve oom-killer

This commit is contained in:
世界
2026-04-23 08:12:53 +08:00
parent 7a57cfeb88
commit 3ed2341355
4 changed files with 41 additions and 1 deletions
+28 -1
View File
@@ -62,6 +62,9 @@ public class ExtensionProfile: ObservableObject {
self.connection = connection
self.status = connection.status
self.connectedDate = connection.connectedDate
if connection.status == .disconnected {
Self.schedulePromoteOOMDraft()
}
#if os(iOS)
if #available(iOS 16.0, *) {
if connection.status == .connected || connection.status == .disconnected {
@@ -73,6 +76,26 @@ public class ExtensionProfile: ObservableObject {
}
}
private static func schedulePromoteOOMDraft() {
Task.detached {
try? await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC)
#if os(macOS)
if Variant.useSystemExtension {
guard HelperServiceManager.rootHelperStatus == .enabled else {
return
}
do {
try RootHelperClient.shared.promoteOOMDraft()
} catch {
logger.warning("promote OOM draft: \(error.localizedDescription)")
}
return
}
#endif
LibboxPromoteOOMDraft()
}
}
#if os(iOS)
@available(iOS 16.0, *)
private static func signalFileProviderChanges() {
@@ -291,7 +314,11 @@ public class ExtensionProfile: ObservableObject {
if managers.isEmpty {
return nil
}
return ExtensionProfile(managers[0])
let profile = ExtensionProfile(managers[0])
if profile.status == .disconnected {
schedulePromoteOOMDraft()
}
return profile
}
public static func install() async throws {