mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-19 12:56:06 +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] {
|
if let transfer = incomingConnections[id] {
|
||||||
transfer.cancel()
|
transfer.cancel()
|
||||||
}
|
}
|
||||||
if let transfer = outgoingTransfers[id] {
|
if let info = outgoingTransfers[id] {
|
||||||
transfer.connection.cancel()
|
info.connection.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,7 +650,6 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
|||||||
if accessSuccess {
|
if accessSuccess {
|
||||||
url.stopAccessingSecurityScopedResource()
|
url.stopAccessingSecurityScopedResource()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("[NearbyConnectionManager] File URL \(url) does not point to a security scoped resource")
|
log("[NearbyConnectionManager] File URL \(url) does not point to a security scoped resource")
|
||||||
|
|||||||
@@ -63,6 +63,18 @@ class OutboundNearbyConnection: NearbyConnection {
|
|||||||
override func disconnect() {
|
override func disconnect() {
|
||||||
super.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 {
|
if let error = lastError {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.delegate?.failedWithError(connection: self, error: error)
|
self.delegate?.failedWithError(connection: self, error: error)
|
||||||
|
|||||||
Reference in new issue
Block a user