mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-15 01:33:25 +01:00
Fixes deadlock when getting/setting progress for an app
This commit is contained in:
@@ -1960,25 +1960,31 @@ private extension AppManager
|
|||||||
|
|
||||||
func progress(for operation: AppOperation) -> Progress?
|
func progress(for operation: AppOperation) -> Progress?
|
||||||
{
|
{
|
||||||
|
// Access outside critical section to avoid deadlock due to `bundleIdentifier` potentially calling performAndWait() on main thread.
|
||||||
|
let bundleID = operation.bundleIdentifier
|
||||||
|
|
||||||
os_unfair_lock_lock(self.progressLock)
|
os_unfair_lock_lock(self.progressLock)
|
||||||
defer { os_unfair_lock_unlock(self.progressLock) }
|
defer { os_unfair_lock_unlock(self.progressLock) }
|
||||||
|
|
||||||
switch operation
|
switch operation
|
||||||
{
|
{
|
||||||
case .install, .update: return self.installationProgress[operation.bundleIdentifier]
|
case .install, .update: return self.installationProgress[bundleID]
|
||||||
case .refresh, .activate, .deactivate, .backup, .restore: return self.refreshProgress[operation.bundleIdentifier]
|
case .refresh, .activate, .deactivate, .backup, .restore: return self.refreshProgress[bundleID]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func set(_ progress: Progress?, for operation: AppOperation)
|
func set(_ progress: Progress?, for operation: AppOperation)
|
||||||
{
|
{
|
||||||
|
// Access outside critical section to avoid deadlock due to `bundleIdentifier` potentially calling performAndWait() on main thread.
|
||||||
|
let bundleID = operation.bundleIdentifier
|
||||||
|
|
||||||
os_unfair_lock_lock(self.progressLock)
|
os_unfair_lock_lock(self.progressLock)
|
||||||
defer { os_unfair_lock_unlock(self.progressLock) }
|
defer { os_unfair_lock_unlock(self.progressLock) }
|
||||||
|
|
||||||
switch operation
|
switch operation
|
||||||
{
|
{
|
||||||
case .install, .update: self.installationProgress[operation.bundleIdentifier] = progress
|
case .install, .update: self.installationProgress[bundleID] = progress
|
||||||
case .refresh, .activate, .deactivate, .backup, .restore: self.refreshProgress[operation.bundleIdentifier] = progress
|
case .refresh, .activate, .deactivate, .backup, .restore: self.refreshProgress[bundleID] = progress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user