diff --git a/kitty/file_transmission.py b/kitty/file_transmission.py index 916eb438d..dbfe19505 100644 --- a/kitty/file_transmission.py +++ b/kitty/file_transmission.py @@ -539,7 +539,7 @@ class SourceFile: self.ttype = ftc.ttype self.waiting_for_signature = True if self.ttype is TransmissionType.rsync else False self.transmitted = False - self.stat = os.stat(self.path) + self.stat = os.stat(self.path, follow_symlinks=False) if stat.S_ISDIR(self.stat.st_mode): raise TransmissionError(ErrorCode.EINVAL, msg='Cannot send a directory', file_id=self.file_id) self.compressor: Union[ZlibCompressor, IdentityCompressor] = IdentityCompressor() diff --git a/kitty_tests/file_transmission.py b/kitty_tests/file_transmission.py index 6ebec2c53..f7f5df5af 100644 --- a/kitty_tests/file_transmission.py +++ b/kitty_tests/file_transmission.py @@ -190,6 +190,8 @@ class TestFileTransmission(BaseTest): data = os.urandom(16 * 1024) with open(src, 'wb') as f: f.write(data) + sl = os.path.join(base, 'src.link') + os.symlink(src, sl) for compress in ('none', 'zlib'): ft = FileTransmission() self.responses = [] @@ -203,6 +205,10 @@ class TestFileTransmission(BaseTest): if compress == 'zlib': received = ZlibDecompressor()(received, True) self.ae(data, received) + ft.test_responses = [] + ft.handle_serialized_command(serialized_cmd(action='file', file_id='sl', name=sl, compression=compress)) + received = b''.join(x['data'] for x in ft.test_responses) + self.ae(received.decode('utf-8'), src) def test_file_put(self): # send refusal