mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
- Isolated global state into an actor. - Updated declarations and calls to reflect asynchronicity. - The replacement of the enumerator with subpathsOfDirectory(atPath:) was suggested by Copilot to necessarily avoid the use of synchronous enumeration in an asynchronous context. - Updated README. Signed-off-by: Iva Horn <iva.horn@icloud.com>
31 lines
614 B
Swift
31 lines
614 B
Swift
// SPDX-FileCopyrightText: Nextcloud GmbH
|
|
// SPDX-FileCopyrightText: 2025 Iva Horn
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import Foundation
|
|
|
|
///
|
|
/// Global state object.
|
|
///
|
|
actor State {
|
|
weak private var process: Process?
|
|
|
|
static let shared = State()
|
|
|
|
///
|
|
/// Register the shell command process.
|
|
///
|
|
func register(_ process: Process) {
|
|
self.process = process
|
|
}
|
|
|
|
///
|
|
/// Terminate any previously registered shell command process.
|
|
///
|
|
/// Silently fails in case no process is registered.
|
|
///
|
|
func terminate() {
|
|
process?.terminate()
|
|
}
|
|
}
|