node-sftp-server icon indicating copy to clipboard operation
node-sftp-server copied to clipboard

Javascript-ify the `attrs` attribute used in various places (including directory listings)

Open uberbrady opened this issue 8 years ago • 0 comments

Right now we respond with some very low-level, close-to-the-metal things in our stat implementation, as well as our directory-listing implementation. Like:

    statresponder.is_file();         // Tells statresponder that we're describing a file.
    statresponder.permissions = 644; // Octal permissions, like what you'd send to a chmod command
    statresponder.uid = 1;           // User ID that owns the file.
    statresponder.gid = 1;           // Group ID that owns the file.
    statresponder.size = 1234;       // File size in bytes.
    statresponder.atime = 123456;    // Created at (unix style timestamp in seconds-from-epoch).
    statresponder.mtime = 123456;    // Modified at (unix style timestamp in seconds-from-epoch).

    stat.file();   // Tells the statter to actually send the values above down the wire.

and, in directory listings, as:

var attrs = {
    'mode': fs.constants.S_IFDIR | 0o644    // Bit mask of file type and permissions 
    'permissions': 644,                     // Octal permissions, like what you'd send to a chmod command
    'uid': 1,                               // User ID that owns the file.
    'gid': 1,                               // Group ID that owns the file.
    'size': 1234,                           // File size in bytes.
    'atime': 123456,                        // Created at (unix style timestamp in seconds-from-epoch).
    'mtime': 123456                         // Modified at (unix style timestamp in seconds-from-epoch).
}

We should support something a little more pleasant and Javascript-ey. I don't know how we'd want to handle the mode/permissions, or whatever, but definitely for the atime and mtime values, it'd be nice to send back a Javascript datetime object instead (and have the library do the hard work of parsing things).

uberbrady avatar Jan 07 '17 02:01 uberbrady