mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 22:05:21 +00:00
Copy imported files before sending to preserve access
This commit is contained in:
@@ -2112,8 +2112,20 @@ private extension ContentView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleImportedFile(url: URL) async {
|
func handleImportedFile(url: URL) async {
|
||||||
|
do {
|
||||||
|
let fileManager = FileManager.default
|
||||||
|
let tempDir = fileManager.temporaryDirectory
|
||||||
|
let fileName = url.lastPathComponent.isEmpty ? "attachment" : url.lastPathComponent
|
||||||
|
let destination = tempDir.appendingPathComponent(UUID().uuidString + "_" + fileName)
|
||||||
|
if fileManager.fileExists(atPath: destination.path) {
|
||||||
|
try fileManager.removeItem(at: destination)
|
||||||
|
}
|
||||||
|
try fileManager.copyItem(at: url, to: destination)
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
viewModel.sendFileAttachment(from: url)
|
viewModel.sendFileAttachment(from: destination)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
SecureLogger.error("File copy failed before send: \(error)", category: .session)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user