From f75c68237a1d065a5e89fe1a839568a5dd913c41 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 2 Jan 2020 09:00:01 +0100 Subject: [PATCH 1/4] docs: remove format option from mfs commands (#575) UnixFS uses `dag-pb` so don't offer the user the option of using other formats. --- SPEC/FILES.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/SPEC/FILES.md b/SPEC/FILES.md index b9b6aaf1..ba412edc 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -774,7 +774,6 @@ Where: - `to` is the path of the destination to copy to - `options` is an optional Object that might contain the following keys: - `parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false) - - `format` is what type of nodes to write any newly created directories as (default: `dag-pb`) - `hashAlg` is which algorithm to use when creating CIDs for newly created directories. (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343) - `flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true) @@ -818,7 +817,6 @@ Where: - `path` is the path to the directory to make - `options` is an optional Object that might contain the following keys: - `parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false) - - `format` is what type of nodes to write any newly created directories as (default: `dag-pb`) - `hashAlg` is which algorithm to use when creating CIDs for newly created directories (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343) - `flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true) @@ -1061,7 +1059,6 @@ Where: - `to` is the path of the destination to move to - `options` is an optional Object that might contain the following keys: - `parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false) - - `format` is what type of nodes to write any newly created directories as (default: `dag-pb`) - `hashAlg` is which algorithm to use when creating CIDs for newly created directories (default: `sha2-256`) [The list of all possible values]( https://github.com/multiformats/js-multihash/blob/master/src/constants.js#L5-L343) - `flush` is a Boolean value to decide whether or not to immediately flush MFS changes to disk (default: true) From e10e85dca86e84997ee7c667b83b0c56c8f5af63 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 9 Jan 2020 10:21:42 +0000 Subject: [PATCH 2/4] docs: add mode and mtime and .touch/.chmod mfs commands (#572) * docs: add mode and mtime and .touch/.chmod mfs commands * docs: update arg/return types * test: updates tests to use timespecs * fix: remove cumulativeSize as it changes based on timestamps * docs: update SPEC/FILES.md * docs: update SPEC/FILES.md * docs: remove format * Update SPEC/FILES.md Co-Authored-By: Steven Allen * docs: more detail about mtime values * docs: remove octal as string * docs: remove mode as strings * fix: fix up tests for optional mtime Co-authored-by: Steven Allen --- SPEC/FILES.md | 128 ++++++++++++++++++++++-- package.json | 4 +- src/files-mfs/chmod.js | 62 ++++++++++++ src/files-mfs/cp.js | 71 +++++++++++++ src/files-mfs/index.js | 4 +- src/files-mfs/ls-pull-stream.js | 36 +++---- src/files-mfs/ls-readable-stream.js | 36 +++---- src/files-mfs/ls.js | 92 +++++++++++------ src/files-mfs/mkdir.js | 68 +++++++++++++ src/files-mfs/stat.js | 2 - src/files-mfs/touch.js | 126 +++++++++++++++++++++++ src/files-mfs/write.js | 72 +++++++++++++ src/files-regular/add-from-fs.js | 3 +- src/files-regular/add.js | 74 ++++++++++++++ src/files-regular/ls-pull-stream.js | 93 ++++++++--------- src/files-regular/ls-readable-stream.js | 93 ++++++++--------- src/files-regular/ls.js | 120 ++++++++++++---------- 17 files changed, 852 insertions(+), 232 deletions(-) create mode 100644 src/files-mfs/chmod.js create mode 100644 src/files-mfs/touch.js diff --git a/SPEC/FILES.md b/SPEC/FILES.md index ba412edc..419cb6dc 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -24,6 +24,7 @@ The regular, top-level API for add, cat, get and ls Files on IPFS The Files API, aka MFS (Mutable File System) _Explore the Mutable File System through interactive coding challenges in our [ProtoSchool tutorial](https://proto.school/#/mutable-file-system/)._ + - [files.chmod](#fileschmod) - [files.cp](#filescp) - [files.flush](#filesflush) - [files.ls](#filesls) @@ -36,6 +37,7 @@ _Explore the Mutable File System through interactive coding challenges in our [P - [files.readReadableStream](#filesreadreadablestream) - [files.rm](#filesrm) - [files.stat](#filesstat) + - [files.touch](#filestouch) - [files.write](#fileswrite) ### ⚠️ Note @@ -58,6 +60,8 @@ Where `data` may be: { path: '/tmp/myfile.txt', // The file path content: // A Buffer, Readable Stream, Pull Stream or File with the contents of the file + mode: // optional integer mode to store the entry with + mtime: