X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=src%2Fallmydata%2Ffrontends%2Fftpd.py;h=b00bd9349ecfb4d3b15486f8637380ded7e3322b;hb=cc68a81326a61cb4f6f731f9ee0a84a867f5c32c;hp=dbcb8318a5a15658f4b52aa3fc9f59f730b6220d;hpb=b36903d02c8f9efbb5ac629c074075f7008e9051;p=tahoe-lafs%2Ftahoe-lafs.git diff --git a/src/allmydata/frontends/ftpd.py b/src/allmydata/frontends/ftpd.py index dbcb8318..b00bd934 100644 --- a/src/allmydata/frontends/ftpd.py +++ b/src/allmydata/frontends/ftpd.py @@ -62,18 +62,16 @@ class WriteFile: class NoParentError(Exception): pass -if hasattr(filepath, "Permissions"): - # filepath.Permissions was added in Twisted-11.1.0, but we're compatible - # back to 11.0.0 (on windows). Fortunately we don't really need to - # provide anything more than an int until Twisted-15.0.0 . - class IntishPermissions(filepath.Permissions): - def __init__(self, statModeInt): - self.statModeInt = statModeInt - filepath.Permissions.__init__(self, statModeInt) - def __and__(self, other): - return self.statModeInt & other -else: - IntishPermissions = lambda statModeInt: statModeInt +# filepath.Permissions was added in Twisted-11.1.0, which we require. Twisted +# <15.0.0 expected an int, and only does '&' on it. Twisted >=15.0.0 expects +# a filepath.Permissions. This satisfies both. + +class IntishPermissions(filepath.Permissions): + def __init__(self, statModeInt): + self._tahoe_statModeInt = statModeInt + filepath.Permissions.__init__(self, statModeInt) + def __and__(self, other): + return self._tahoe_statModeInt & other class Handler: implements(ftp.IFTPShell) @@ -214,10 +212,11 @@ class Handler: elif key == "directory": value = isdir elif key == "permissions": - # Twisted-14.0.2 expected an int, and used it in a rendering - # function that did (mode & NUMBER). Twisted-15.0.0 expects a + # Twisted-14.0.2 (and earlier) expected an int, and used it + # in a rendering function that did (mode & NUMBER). + # Twisted-15.0.0 expects a # twisted.python.filepath.Permissions , and calls its - # .shorthand() method. Try to provide both. + # .shorthand() method. This provides both both. value = IntishPermissions(0600) elif key == "hardlinks": value = 1