feat(*): add sender to files pack result

This commit is contained in:
ksenia312
2024-02-04 22:25:57 +01:00
parent a1ac4488ca
commit d6840a4313
25 changed files with 199 additions and 152 deletions
+4 -2
View File
@@ -47,15 +47,17 @@ extension NearbySession: MCSessionDelegate {
func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL?, withError error: Error?) {
guard let localURL = localURL else { return }
let destinationURL = localURL.deletingLastPathComponent().appendingPathComponent("\(resourceName)")
var destinationURL = localURL.deletingLastPathComponent().appendingPathComponent("\(resourceName)")
if FileManager.default.fileExists(atPath: destinationURL.path) {
destinationURL = localURL.deletingLastPathComponent().appendingPathComponent("New_\(resourceName)")
}
do {
try FileManager.default.moveItem(at: localURL, to: destinationURL)
} catch {
Logger.error(message: "Error moving file: \(error)")
}
NotificationCenter.default.post(
name: ON_RESOURCE_RECEIVED,
object: nil,