Skip to content

Commit

Permalink
Convert deinit crash into warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Joannis committed Aug 22, 2024
1 parent bf3dfaa commit 11566ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/Citadel/SFTP/Client/SFTPFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public final class SFTPFile {
public var logger: Logging.Logger { self.client.logger }

deinit {
assert(!self.client.isActive || !self.isActive, "SFTPFile deallocated without being closed first")
if client.isActive && self.isActive {
self.logger.warning("SFTPFile deallocated without being closed first")
}
}

/// Read the attributes of the file. This is equivalent to the `stat()` system call.
Expand Down
1 change: 1 addition & 0 deletions Tests/CitadelTests/Citadel2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ final class Citadel2Tests: XCTestCase {
_ = try await file.read(from: UInt64(i * 32_768), length: 32_768)
i += 1
}
try await file.close()
}

func testConnectToOpenSSHServer() async throws {
Expand Down

0 comments on commit 11566ed

Please sign in to comment.