From 995c447435a98a4220eae4e8f132ff08d9e7d2fb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 26 Jul 2023 10:42:18 +0530 Subject: [PATCH] Get the multi file tests working for the receive kitten --- kittens/transfer/receive.go | 4 ++-- kitty_tests/file_transmission.py | 38 ++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/kittens/transfer/receive.go b/kittens/transfer/receive.go index e31d5969b..8c1452e1a 100644 --- a/kittens/transfer/receive.go +++ b/kittens/transfer/receive.go @@ -391,8 +391,8 @@ func (self *manager) request_files() transmit_iterator { if f == nil { return 0, files_done } - read_signature := self.use_rsync - if read_signature && f.ftype == FileType_regular { + read_signature := self.use_rsync && f.ftype == FileType_regular + if read_signature { if s, err := os.Lstat(f.expanded_local_path); err == nil { read_signature = s.Size() > 4096 } else { diff --git a/kitty_tests/file_transmission.py b/kitty_tests/file_transmission.py index 52722c9b8..7b05dfb24 100644 --- a/kitty_tests/file_transmission.py +++ b/kitty_tests/file_transmission.py @@ -165,6 +165,7 @@ class PtyFileTransmission(FileTransmission): self.pty.callbacks.ftc = self def write_ftc_to_child(self, payload: FileTransmissionCommand, appendleft: bool = False, use_pending: bool = True) -> bool: + # print('to kitten:', payload) self.pty.write_to_child('\x1b]' + payload.serialize(prefix_with_osc_code=True) + '\x1b\\', flush=False) return True @@ -172,7 +173,7 @@ class PtyFileTransmission(FileTransmission): class TransferPTY(PTY): def __init__(self, cmd, cwd, allow=True, env=None): - super().__init__(cmd, cwd=cwd, env=env) + super().__init__(cmd, cwd=cwd, env=env, rows=200, columns=120) self.fc = PtyFileTransmission(self, allow=allow) @@ -368,20 +369,6 @@ class TestFileTransmission(BaseTest): single_file('--compress=always') single_file('--transmit-deltas', '--compress=never') - def test_transfer_receive(self): - self.direction_receive = True - self.basic_transfer_tests() - - def test_transfer_send(self): - self.basic_transfer_tests() - src = os.path.join(self.tdir, 'src') - - # remote home - fname = 'tstest-file' - with set_paths(home=self.tdir), self.run_kitten([src, '~/'+fname]) as pty: - pty.wait_till_child_exits(require_exit_code=0) - os.remove(os.path.expanduser('~/'+fname)) - def multiple_files(*cmd): src = os.path.join(self.tdir, 'msrc') dest = os.path.join(self.tdir, 'mdest') @@ -398,7 +385,7 @@ class TestFileTransmission(BaseTest): mtime = st.st_mtime_ns if stat.S_ISDIR(st.st_mode): mtime = 0 # mtime is flaky for dirs on CI even empty ones - return Entry(os.path.relpath(path, base), mtime, st.st_mode, st.st_nlink) + return Entry(os.path.relpath(path, base), mtime, oct(st.st_mode), st.st_nlink) def se(path): e = entry(path) @@ -458,6 +445,25 @@ class TestFileTransmission(BaseTest): multiple_files('--transmit-deltas') multiple_files('--transmit-deltas') + def test_transfer_receive(self): + self.direction_receive = True + self.basic_transfer_tests() + src = os.path.join(self.tdir, 'src') + with open(src, 'wb') as s: + s.write(self.src_data) + + def test_transfer_send(self): + self.basic_transfer_tests() + src = os.path.join(self.tdir, 'src') + with open(src, 'wb') as s: + s.write(self.src_data) + + # remote home + fname = 'tstest-file' + with set_paths(home=self.tdir), self.run_kitten([src, '~/'+fname]) as pty: + pty.wait_till_child_exits(require_exit_code=0) + os.remove(os.path.expanduser('~/'+fname)) + # mirror mode src_home = os.path.join(self.tdir, 'misrc') os.mkdir(src_home)