Fix symlink transmission
This commit is contained in:
parent
c4b3723372
commit
950edb1110
@ -539,7 +539,7 @@ class SourceFile:
|
|||||||
self.ttype = ftc.ttype
|
self.ttype = ftc.ttype
|
||||||
self.waiting_for_signature = True if self.ttype is TransmissionType.rsync else False
|
self.waiting_for_signature = True if self.ttype is TransmissionType.rsync else False
|
||||||
self.transmitted = 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):
|
if stat.S_ISDIR(self.stat.st_mode):
|
||||||
raise TransmissionError(ErrorCode.EINVAL, msg='Cannot send a directory', file_id=self.file_id)
|
raise TransmissionError(ErrorCode.EINVAL, msg='Cannot send a directory', file_id=self.file_id)
|
||||||
self.compressor: Union[ZlibCompressor, IdentityCompressor] = IdentityCompressor()
|
self.compressor: Union[ZlibCompressor, IdentityCompressor] = IdentityCompressor()
|
||||||
|
|||||||
@ -190,6 +190,8 @@ class TestFileTransmission(BaseTest):
|
|||||||
data = os.urandom(16 * 1024)
|
data = os.urandom(16 * 1024)
|
||||||
with open(src, 'wb') as f:
|
with open(src, 'wb') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
sl = os.path.join(base, 'src.link')
|
||||||
|
os.symlink(src, sl)
|
||||||
for compress in ('none', 'zlib'):
|
for compress in ('none', 'zlib'):
|
||||||
ft = FileTransmission()
|
ft = FileTransmission()
|
||||||
self.responses = []
|
self.responses = []
|
||||||
@ -203,6 +205,10 @@ class TestFileTransmission(BaseTest):
|
|||||||
if compress == 'zlib':
|
if compress == 'zlib':
|
||||||
received = ZlibDecompressor()(received, True)
|
received = ZlibDecompressor()(received, True)
|
||||||
self.ae(data, received)
|
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):
|
def test_file_put(self):
|
||||||
# send refusal
|
# send refusal
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user