Changeset 03134ee in trunk


Ignore:
Timestamp:
2010-02-20T06:13:13Z (15 years ago)
Author:
david-sarah <david-sarah@…>
Branches:
master
Children:
9741b96
Parents:
b7c0248
Message:

Improve behaviour of 'tahoe ls' for unknown objects, addressing kevan's comments

Location:
src/allmydata/scripts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/scripts/cli.py

    rb7c0248 r03134ee  
    8686        self.where = where
    8787
    88     longdesc = """List the contents of some portion of the grid."""
     88    longdesc = """
     89    List the contents of some portion of the grid.
     90
     91    When the -l or --long option is used, each line is shown in the
     92    following format:
     93
     94    drwx <size> <date/time> <name in this directory>
     95
     96    where each of the letters on the left may be replaced by '-'.
     97    If 'd' is present, it indicates that the object is a directory.
     98    If the 'd' is replaced by a '?', the object type is unknown.
     99    'rwx' is a Unix-like permissions mask: if the mask includes 'w',
     100    then the object is writable through its link in this directory.
     101    The 'x' is a legacy of Unix filesystems. In Tahoe it is used
     102    only to indicate that the contents of a directory can be listed.
     103
     104    Directories have no size, so their size field is shown as '-'.
     105    Otherwise the size of the file, when known, is given in bytes.
     106    The size of mutable files or unknown objects is shown as '?'.
     107
     108    The date/time shows when this link in the Tahoe filesystem was
     109    last modified.
     110    """
    89111
    90112class GetOptions(VDriveOptions):
  • TabularUnified src/allmydata/scripts/common.py

    rb7c0248 r03134ee  
    140140    path = path.strip()
    141141    if uri.has_uri_prefix(path):
    142         # The only way to get a sub-path is to use URI:blah:./foo, and we
    143         # strip out the :./ sequence.
     142        # We used to require "URI:blah:./foo" in order to get a subpath,
     143        # stripping out the ":./" sequence. We still allow that for compatibility,
     144        # but now also allow just "URI:blah/foo".
    144145        sep = path.find(":./")
    145146        if sep != -1:
    146147            return path[:sep], path[sep+3:]
     148        sep = path.find("/")
     149        if sep != -1:
     150            return path[:sep], path[sep+1:]
    147151        return path, ""
    148152    colon = path.find(":")
  • TabularUnified src/allmydata/scripts/tahoe_ls.py

    rb7c0248 r03134ee  
    5656    if nodetype == "dirnode":
    5757        children = d['children']
    58     elif nodetype == "filenode":
     58    else:
    5959        childname = path.split("/")[-1]
    6060        children = {childname: (nodetype, d)}
     
    6868    # variable-width ones.
    6969    rows = []
     70    has_unknowns = False
    7071
    7172    for name in childnames:
     
    102103        elif childtype == "filenode":
    103104            t0 = "-"
    104             size = str(child[1]['size'])
     105            size = str(child[1].get("size", "?"))
    105106            classify = ""
    106107            if rw_uri:
    107108                classify = "*"
    108109        else:
     110            has_unknowns = True
    109111            t0 = "?"
    110112            size = "?"
     
    162164        print >>stdout, (fmt % tuple(row)).rstrip()
    163165
     166    if has_unknowns:
     167        print >>stderr, "\nThis listing included unknown objects. Using a webapi server that supports" \
     168                        "\na later version of Tahoe may help."
     169
    164170    return 0
    165171
Note: See TracChangeset for help on using the changeset viewer.