Skip to content

Commit ca214ff

Browse files
committed
transfer receive: ensure open files are closed
1 parent 7159257 commit ca214ff

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kittens/transfer/receive.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def __init__(self, ftc: FileTransmissionCommand):
7272
def __repr__(self) -> str:
7373
return f'File(rpath={self.remote_path!r}, lpath={self.expanded_local_path!r})'
7474

75+
def close(self) -> None:
76+
if self.actual_file is not None:
77+
self.actual_file.close()
78+
self.actual_file = None
79+
7580
def write_data(self, data: bytes, is_last: bool) -> int:
7681
self.received_bytes += len(data)
7782
data = self.decompressor(data, is_last)
@@ -639,6 +644,8 @@ def receive_main(cli_opts: TransferCLIOptions, args: List[str]) -> None:
639644
loop = Loop()
640645
handler = Receive(cli_opts, spec, dest)
641646
loop.loop(handler)
647+
for f in handler.manager.files:
648+
f.close()
642649
tsf = dsz = ssz = 0
643650
for f in handler.manager.files:
644651
if f.expect_diff:

0 commit comments

Comments
 (0)