Opened 7 years ago

Last modified 7 years ago

#7833 defect new

IFTPShell.list() still claims "permissions" should be a bitvector/int

Reported by: warner Owned by:
Priority: normal Milestone:
Component: ftp Keywords:
Cc: itamarst Branch:


We noticed recently that Tahoe-LAFS's FTP frontend stopped working, and we think we've tracked it down to a change in the behavior of Twisted's FTP server. has details. It appears that twisted.protocols.ftp now expects permissions to be an instance of twisted.python.filepath.Permissions, because it calls the .shorthand() method to get a string representation. Our implementation of ftp.IFTPShell still returns an int (synthesized from Tahoe's internal filesystem metadata: there is no real file-on-disk here). The old Twisted formatted that int with:

def formatMode(mode):
    return ''.join([mode & (256 >> n) and 'rwx'[n % 3] or '-' for n in range(9)])

We can upgrade to match (by just creating a Permissions), but I noticed that the docstring for IFTPShell.list hasn't been updated (twisted/protocols/ line 1646):

            - C{'permissions'}: a bitvector (see os.stat(foo).st_mode)

I don't know if there's a good way for us to be compatible with both versions. It looks like 14.0.2 was the last version that accepted an int, and 15.0.0 was the first that expected a filepath.Permissions. I suppose we could rig up an object that implements shorthand() and overrides __and__ to work with both, but.. eww. Is there anything we can test to indicate which kind of object to return?

Change History (1)

comment:1 Changed 7 years ago by DefaultCC Plugin

Cc: itamarst added
Note: See TracTickets for help on using tickets.