From: david-sarah Date: Fri, 28 Jan 2011 06:22:49 +0000 (-0800) Subject: SFTP: report unknown sizes as "0" instead of "?", to satisfy some clients. fixes... X-Git-Tag: trac-5000~1 X-Git-Url: https://git.rkrishnan.org/pf/content/de.html?a=commitdiff_plain;h=ed67df866cce3b6a7ab107542c476f13006df228;p=tahoe-lafs%2Ftahoe-lafs.git SFTP: report unknown sizes as "0" instead of "?", to satisfy some clients. fixes #1337 --- diff --git a/src/allmydata/frontends/sftpd.py b/src/allmydata/frontends/sftpd.py index a38196fc..f7d345ba 100644 --- a/src/allmydata/frontends/sftpd.py +++ b/src/allmydata/frontends/sftpd.py @@ -142,7 +142,10 @@ def _lsLine(name, attrs): st_gid = "tahoe" st_mtime = attrs.get("mtime", 0) st_mode = attrs["permissions"] - st_size = attrs.get("size", "?") + + # Some clients won't tolerate '?' in the size field (#1337). + st_size = attrs.get("size", 0) + # We don't know how many links there really are to this object. st_nlink = 1 diff --git a/src/allmydata/test/test_sftp.py b/src/allmydata/test/test_sftp.py index e37de5a2..712f4747 100644 --- a/src/allmydata/test/test_sftp.py +++ b/src/allmydata/test/test_sftp.py @@ -293,17 +293,17 @@ class Handler(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, unittest.TestCas gross = u"gro\u00DF".encode("utf-8") expected_root = [ - ('empty_lit_dir', r'dr-xr-xr-x .* \? .* empty_lit_dir$', {'permissions': S_IFDIR | 0555}), + ('empty_lit_dir', r'dr-xr-xr-x .* 0 .* empty_lit_dir$', {'permissions': S_IFDIR | 0555}), (gross, r'-rw-rw-rw- .* 1010 .* '+gross+'$', {'permissions': S_IFREG | 0666, 'size': 1010}), # The fall of the Berlin wall may have been on 9th or 10th November 1989 depending on the gateway's timezone. - #('loop', r'drwxrwxrwx .* \? Nov (09|10) 1989 loop$', {'permissions': S_IFDIR | 0777}), - ('loop', r'drwxrwxrwx .* \? .* loop$', {'permissions': S_IFDIR | 0777}), - ('mutable', r'-rw-rw-rw- .* \? .* mutable$', {'permissions': S_IFREG | 0666}), - ('readonly', r'-r--r--r-- .* \? .* readonly$', {'permissions': S_IFREG | 0444}), + #('loop', r'drwxrwxrwx .* 0 Nov (09|10) 1989 loop$', {'permissions': S_IFDIR | 0777}), + ('loop', r'drwxrwxrwx .* 0 .* loop$', {'permissions': S_IFDIR | 0777}), + ('mutable', r'-rw-rw-rw- .* 0 .* mutable$', {'permissions': S_IFREG | 0666}), + ('readonly', r'-r--r--r-- .* 0 .* readonly$', {'permissions': S_IFREG | 0444}), ('small', r'-rw-rw-rw- .* 10 .* small$', {'permissions': S_IFREG | 0666, 'size': 10}), ('small2', r'-rw-rw-rw- .* 26 .* small2$', {'permissions': S_IFREG | 0666, 'size': 26}), - ('tiny_lit_dir', r'dr-xr-xr-x .* \? .* tiny_lit_dir$', {'permissions': S_IFDIR | 0555}), - ('unknown', r'\?--------- .* \? .* unknown$', {'permissions': 0}), + ('tiny_lit_dir', r'dr-xr-xr-x .* 0 .* tiny_lit_dir$', {'permissions': S_IFDIR | 0555}), + ('unknown', r'\?--------- .* 0 .* unknown$', {'permissions': 0}), ] d.addCallback(lambda ign: self.handler.openDirectory(""))