mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-22 06:15:59 +00:00
Catch errors when storage is not sufficient
This commit is contained in:
1 parent
404e25d3bd
commit
2939990607
3 files changed
+26
-15
No files matched your search
@@ -64,19 +64,23 @@ class InboundNearbyConnection: NearbyConnection {
|
|||||||
try processConnectionResponseFrame(frame)
|
try processConnectionResponseFrame(frame)
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
var smsg: Securemessage_SecureMessage? = nil
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let smsg = try Securemessage_SecureMessage(serializedBytes: frameData)
|
smsg = try Securemessage_SecureMessage(serializedBytes: frameData)
|
||||||
try decryptAndProcessReceivedSecureMessage(smsg)
|
|
||||||
} catch {
|
} catch {
|
||||||
|
|
||||||
log("Error deserializing secure message (probably due to packet filter)")
|
log("Error deserializing secure message (probably due to packet filter)")
|
||||||
lastError = NearbyError.packetFilterError
|
lastError = NearbyError.packetFilterError
|
||||||
protocolError()
|
protocolError()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let smsg = smsg {
|
||||||
|
try decryptAndProcessReceivedSecureMessage(smsg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
lastError = error
|
lastError = error
|
||||||
log("Deserialization error: \(error) in state \(currentState).")
|
log("Error receiving frame: \(error) in state \(currentState).")
|
||||||
protocolError()
|
protocolError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,9 +121,15 @@ class InboundNearbyConnection: NearbyConnection {
|
|||||||
guard currentOffset + Int64(frame.payloadChunk.body.count) <= fileInfo.meta.size else { throw NearbyError.protocolError("Transferred file size exceeds previously specified value") }
|
guard currentOffset + Int64(frame.payloadChunk.body.count) <= fileInfo.meta.size else { throw NearbyError.protocolError("Transferred file size exceeds previously specified value") }
|
||||||
|
|
||||||
if frame.payloadChunk.body.count > 0 {
|
if frame.payloadChunk.body.count > 0 {
|
||||||
fileInfo.fileHandle?.write(frame.payloadChunk.body)
|
do {
|
||||||
transferredFiles[id]!.bytesTransferred += Int64(frame.payloadChunk.body.count)
|
try fileInfo.fileHandle?.write(contentsOf: frame.payloadChunk.body)
|
||||||
fileInfo.progress?.completedUnitCount = transferredFiles[id]!.bytesTransferred
|
transferredFiles[id]!.bytesTransferred += Int64(frame.payloadChunk.body.count)
|
||||||
|
fileInfo.progress?.completedUnitCount = transferredFiles[id]!.bytesTransferred
|
||||||
|
} catch {
|
||||||
|
log("Error occurred during writing file: \(error.localizedDescription)")
|
||||||
|
|
||||||
|
throw NearbyError.protocolError(error.localizedDescription)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (frame.payloadChunk.flags & 1) == 1 {
|
else if (frame.payloadChunk.flags & 1) == 1 {
|
||||||
try fileInfo.fileHandle?.close()
|
try fileInfo.fileHandle?.close()
|
||||||
|
|||||||
@@ -827,8 +827,8 @@
|
|||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SHARED_BUILD = 48;
|
SHARED_BUILD = 49;
|
||||||
SHARED_VERSION = 1.10;
|
SHARED_VERSION = 1.10.1;
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
};
|
};
|
||||||
@@ -886,8 +886,8 @@
|
|||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SHARED_BUILD = 48;
|
SHARED_BUILD = 49;
|
||||||
SHARED_VERSION = 1.10;
|
SHARED_VERSION = 1.10.1;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -465,14 +465,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
switch ne {
|
switch ne {
|
||||||
case .inputOutput:
|
case .inputOutput:
|
||||||
description = "I/O Error"
|
description = "I/O Error"
|
||||||
case .protocolError:
|
case .protocolError(errorMessage: let errorMessage):
|
||||||
description = NSLocalizedString("Error.Protocol", value: "Communication error", comment: "") + "(\(ne.localizedDescription))"
|
log("Protocol error ")
|
||||||
|
description = NSLocalizedString("Error.Protocol", value: "Communication error", comment: "") + " (\(errorMessage))"
|
||||||
case .packetFilterError:
|
case .packetFilterError:
|
||||||
openAlert(type: .NetworkFilter)
|
openAlert(type: .NetworkFilter)
|
||||||
plusWindow?.close()
|
plusWindow?.close()
|
||||||
return
|
return
|
||||||
case .requiredFieldMissing:
|
case .requiredFieldMissing(errorMessage: let errorMessage):
|
||||||
description = NSLocalizedString("Error.Protocol", value: "Communication error", comment: "") + "(\(ne.localizedDescription))"
|
description = NSLocalizedString("Error.Protocol", value: "Communication error", comment: "") + "(\(errorMessage))"
|
||||||
case .ukey2:
|
case .ukey2:
|
||||||
description = NSLocalizedString("Error.Crypto", value: "Encryption error", comment: "") + "(\(ne.localizedDescription))"
|
description = NSLocalizedString("Error.Crypto", value: "Encryption error", comment: "") + "(\(ne.localizedDescription))"
|
||||||
case .canceled(reason: _):
|
case .canceled(reason: _):
|
||||||
|
|||||||
Reference in new issue
Block a user