mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Automatically delete temporary files after file transfer
This commit is contained in:
1 parent
24a0202ae9
commit
733ed8bec8
2 files changed
+14
-3
No files matched your search
@@ -410,8 +410,8 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
||||
if let transfer = incomingConnections[id] {
|
||||
transfer.cancel()
|
||||
}
|
||||
if let transfer = outgoingTransfers[id] {
|
||||
transfer.connection.cancel()
|
||||
if let info = outgoingTransfers[id] {
|
||||
info.connection.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,7 +650,6 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
||||
if accessSuccess {
|
||||
url.stopAccessingSecurityScopedResource()
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
log("[NearbyConnectionManager] File URL \(url) does not point to a security scoped resource")
|
||||
|
||||
@@ -63,6 +63,18 @@ class OutboundNearbyConnection: NearbyConnection {
|
||||
override func disconnect() {
|
||||
super.disconnect()
|
||||
|
||||
// delete all files
|
||||
for url in urlsToSend {
|
||||
|
||||
do {
|
||||
try FileManager.default.removeItem(at: url)
|
||||
log("[OutboundNearbyConnection \(self.id)] Deleted file at \(url).")
|
||||
}
|
||||
catch {
|
||||
log("[OutboundNearbyConnection \(self.id)] Failed to delete file at \(url): \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
if let error = lastError {
|
||||
DispatchQueue.main.async {
|
||||
self.delegate?.failedWithError(connection: self, error: error)
|
||||
|
||||
Reference in new issue
Block a user