SFTP: report unknown sizes as "0" instead of "?", to satisfy some clients. fixes #1337

This commit is contained in:
david-sarah 2011-01-27 22:22:49 -08:00
parent d318122cd2
commit ed67df866c
2 changed files with 11 additions and 8 deletions

View File

@ -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

View File

@ -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(""))