Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion mac/App/Sources/Waypoint/FileSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,16 @@ final class FileSession: Identifiable {
messageIsError = error
}

/// Panel wykonuje jedną operację naraz: kolejna w trakcie przesyłania nie znika po cichu.
private func rejectBusy() {
NSSound.beep()
show(L("files.busy"), error: true)
}

/// Wykonuje pracę na kolejce SFTP; wynik (albo błąd) wraca na wątek główny.
private func run<T>(_ label: String?, work: @escaping (RemoteFS) throws -> T, done: @escaping (T) -> Void) {
guard let c = client, !busy else { return }
guard let c = client else { return }
guard !busy else { rejectBusy(); return }
busy = true
if let label { show(label) }
queue.async { [weak self] in
Expand Down Expand Up @@ -291,6 +298,7 @@ final class FileSession: Identifiable {
/// Wysyłanie plików/katalogów z Findera (przycisk albo przeciągnięcie). Istniejące nazwy → pytanie.
func upload(_ urls: [URL], confirmedOverwrite: Bool = false) {
guard !urls.isEmpty else { return }
guard !busy else { rejectBusy(); return }
let existing = urls.map(\.lastPathComponent).filter { n in entries.contains { $0.name == n } }
if !existing.isEmpty && !confirmedOverwrite {
overwriteQuestion = (existing, urls)
Expand Down Expand Up @@ -398,6 +406,8 @@ final class FileSession: Identifiable {
private func startTransfer<T>(_ label: String, total: UInt64,
work: @escaping (RemoteFS, @escaping (UInt64) -> Bool) throws -> T,
done: @escaping (T) -> Void) {
// Przed zmianą wspólnego stanu: odrzucone przesyłanie nie może skasować anulowania ani opisu trwającego.
guard !busy else { rejectBusy(); return }
cancelFlag.set(false)
let flag = cancelFlag
transfer = Transfer(label: label, done: 0, total: total)
Expand Down
3 changes: 3 additions & 0 deletions mac/App/Sources/Waypoint/FilesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ struct FilesView: View {
ProgressView().controlSize(.small)
}
Button(L("btn.cancel")) { session.cancelTransfer() }
if session.messageIsError, let m = session.message {
Text(m).foregroundStyle(Color.red).lineLimit(1)
}
} else if let m = session.message {
Text(m).foregroundStyle(session.messageIsError ? Color.red : Color.secondary).lineLimit(1)
.textSelection(.enabled)
Expand Down
2 changes: 2 additions & 0 deletions mac/WaypointCore/Sources/WaypointCore/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public enum Strings {
"files.downloading": "Pobieranie: %@",
"files.downloaded": "Pobrano %@ do %@",
"files.deleting": "Usuwanie…",
"files.busy": "Trwa inna operacja: poczekaj, aż się skończy, albo ją anuluj.",
"files.deleted": "Usunięto elementów: %ld",
"files.delete.one": "Usunąć „%@”?",
"files.delete.many": "Usunąć %ld elementów?",
Expand Down Expand Up @@ -821,6 +822,7 @@ public enum Strings {
"files.downloading": "Downloading: %@",
"files.downloaded": "Downloaded %@ to %@",
"files.deleting": "Deleting…",
"files.busy": "Another operation is in progress: wait for it to finish or cancel it.",
"files.deleted": "Deleted items: %ld",
"files.delete.one": "Delete “%@”?",
"files.delete.many": "Delete %ld items?",
Expand Down
Loading