SHA256
fix(ios): bind export cancellation to the originating download
Ignore late picker callbacks that no longer match the active download. Add an Apple-platform regression; Swift formatting, parsing and seven portable policy tests pass locally, but the new WKWebView regression requires Xcode and has not run here.
This commit is contained in:
1 parent
2b9996ff3f
commit
d70c5cc2de
3 files changed
+15
-2
No files matched your search
@@ -103,7 +103,8 @@ final class BrowserModel: NSObject, ObservableObject, WKNavigationDelegate, WKUI
|
|||||||
authentication = WebDestination(url: url)
|
authentication = WebDestination(url: url)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeDownload() {
|
func removeDownload(expected: URL? = nil) {
|
||||||
|
if let expected, download?.url != expected, downloadLocation != expected { return }
|
||||||
download = nil
|
download = nil
|
||||||
if let location = downloadLocation {
|
if let location = downloadLocation {
|
||||||
try? FileManager.default.removeItem(at: location.deletingLastPathComponent())
|
try? FileManager.default.removeItem(at: location.deletingLastPathComponent())
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ struct ContentView: View {
|
|||||||
AuthenticationView(destination: destination.url, model: browser)
|
AuthenticationView(destination: destination.url, model: browser)
|
||||||
}
|
}
|
||||||
.sheet(item: $browser.download) { file in
|
.sheet(item: $browser.download) { file in
|
||||||
ExportView(url: file.url) { browser.removeDownload() }
|
ExportView(url: file.url) { browser.removeDownload(expected: file.url) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,18 @@ final class BrowserModelTests: XCTestCase {
|
|||||||
XCTAssertFalse(model.web.isInspectable)
|
XCTAssertFalse(model.web.isInspectable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
func testLateExportCancellationDoesNotEraseAnotherServersDownload() {
|
||||||
|
let model = BrowserModel()
|
||||||
|
let previous = URL(fileURLWithPath: "/old-selection.txt")
|
||||||
|
let current = URL(fileURLWithPath: "/new-selection.txt")
|
||||||
|
model.download = WebDestination(url: current)
|
||||||
|
model.removeDownload(expected: previous)
|
||||||
|
XCTAssertEqual(model.download?.url, current)
|
||||||
|
model.removeDownload(expected: current)
|
||||||
|
XCTAssertNil(model.download)
|
||||||
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
func testServerErasureReplacesHistoryContext() async {
|
func testServerErasureReplacesHistoryContext() async {
|
||||||
let model = BrowserModel()
|
let model = BrowserModel()
|
||||||
|
|||||||
Reference in new issue
Block a user