Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs-inactive/interface-js-ipfs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.41.1
Choose a base ref
...
head repository: ipfs-inactive/interface-js-ipfs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.42.0
Choose a head ref
  • 8 commits
  • 12 files changed
  • 3 contributors

Commits on Jan 25, 2018

  1. feat: add stats spec

    hacdias authored and daviddias committed Jan 25, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    220483f View commit details
  2. docs: add STATS to readme

    hacdias authored and daviddias committed Jan 25, 2018
    Copy the full SHA
    910c028 View commit details
  3. feat: spec MFS Actions (#206)

    hacdias authored and daviddias committed Jan 25, 2018
    Copy the full SHA
    7431098 View commit details
  4. feat: REPO spec (#207)

    hacdias authored and daviddias committed Jan 25, 2018
    Copy the full SHA
    803a3ef View commit details
  5. fix: Update PUBSUB.md (#204)

    The documentation for `pubsub.ls` is wrong here, although example is accurate. `ls` takes no arguments except for an optional callback; I think the erroneous `topic` argument was copied from the `pubsub.peers` documentation.
    Joel Gustafson authored and daviddias committed Jan 25, 2018
    Copy the full SHA
    0409e3a View commit details
  6. chore: fix lint

    daviddias committed Jan 25, 2018
    Copy the full SHA
    bf25296 View commit details
  7. chore: update contributors

    daviddias committed Jan 25, 2018
    Copy the full SHA
    0282286 View commit details
  8. Copy the full SHA
    290ab91 View commit details
Showing with 1,146 additions and 6 deletions.
  1. +17 −0 CHANGELOG.md
  2. +3 −1 README.md
  3. +293 −1 SPEC/FILES.md
  4. +1 −2 SPEC/PUBSUB.md
  5. +81 −0 SPEC/REPO.md
  6. +114 −0 SPEC/STATS.md
  7. +2 −1 package.json
  8. +7 −1 src/files.js
  9. +2 −0 src/index.js
  10. +428 −0 src/mfs.js
  11. +86 −0 src/repo.js
  12. +112 −0 src/stats.js
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
<a name="0.42.0"></a>
# [0.42.0](https://github.com/ipfs/interface-ipfs-core/compare/v0.41.1...v0.42.0) (2018-01-25)


### Bug Fixes

* Update PUBSUB.md ([#204](https://github.com/ipfs/interface-ipfs-core/issues/204)) ([0409e3a](https://github.com/ipfs/interface-ipfs-core/commit/0409e3a))


### Features

* add stats spec ([220483f](https://github.com/ipfs/interface-ipfs-core/commit/220483f))
* REPO spec ([#207](https://github.com/ipfs/interface-ipfs-core/issues/207)) ([803a3ef](https://github.com/ipfs/interface-ipfs-core/commit/803a3ef))
* spec MFS Actions ([#206](https://github.com/ipfs/interface-ipfs-core/issues/206)) ([7431098](https://github.com/ipfs/interface-ipfs-core/commit/7431098))



<a name="0.41.1"></a>
## [0.41.1](https://github.com/ipfs/interface-ipfs-core/compare/v0.41.0...v0.41.1) (2018-01-19)

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ test.all(common)
## API

In order to be considered "valid", an IPFS core implementation must expose the API described in [/API](/API). You can also use this loose spec as documentation for consuming the core APIs. Here is an outline of the contents of that directory:
In order to be considered "valid", an IPFS core implementation must expose the API described in [/SPEC](/SPEC). You can also use this loose spec as documentation for consuming the core APIs. Here is an outline of the contents of that directory:

- **Files**
- [files](/SPEC/FILES.md)
@@ -101,6 +101,8 @@ In order to be considered "valid", an IPFS core implementation must expose the
- **Node Management**
- [Miscellaneous](/SPEC/MISCELLANEOUS.md)
- [config](/SPEC/CONFIG.md)
- [stats](/SPEC/STATS.md)
- [repo](/SPEC/REPO.md)

## Contribute

294 changes: 293 additions & 1 deletion SPEC/FILES.md
Original file line number Diff line number Diff line change
@@ -387,6 +387,7 @@ pull(

A great source of [examples][] can be found in the tests for this API.


#### `ls`

> Lists a directory from IPFS that is addressed by a valid IPFS Path.
@@ -427,7 +428,7 @@ If no `callback` is passed, a promise is returned.
```JavaScript
const validCID = 'QmQ2r6iMNpky5f1m4cnm3Yqw8VSvjuKpTcK1X7dBR1LkJF'

ipfs.files.ls(validCID, function (err, files) {
ipfs.ls(validCID, function (err, files) {
files.forEach((file) => {
console.log(file.path)
})
@@ -539,6 +540,297 @@ pull(

A great source of [examples][] can be found in the tests for this API.

--------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------

Mutable File System
===================

The Mutable File System (MFS) is a virtual file system on top of IPFS that exposes a Unix like API over a virtual directory. It enables users to write and read from paths without having to worry about updating the graph. It enables things like [ipfs-blob-store](https://github.com/ipfs/ipfs-blob-store) to exist.


#### `cp`

> Copy files.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.cp([from, to], [callback])

Where:

- `from` is the path of the source object to copy.
- `to` is the path of the destination object to copy to.

`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.files.cp(['/src-file', '/dst-file'], (err) => {
if (err) {
console.error(err)
}
})
```

#### `mkdir`

> Make a directory.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.mkdir(path, [options, callback])

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.

`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.files.mkdir('/my/beautiful/directory', (err) => {
if (err) {
console.error(err)
}
})
```

#### `stat`

> Get file or directory status.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.stat(path, [options, callback])

Where:

- `path` is the path to the directory to make.
- `options` is an optional Object that might contain the following keys:
- `hash` is a Boolean value to return only the hash.
- `size` is a Boolean value to return only the size.

`callback` must follow the `function (err, stat) {}` signature, where `err` is an Error if the operation was not successful and `stat` is an Object with the following keys:

- `hash` is a string with the hash.
- `size` is an integer with the size in Bytes.
- `cumulativeSize` is an integer with the cumulative size in Bytes.
- `blocks` is an integer indicating the number of blocks.
- `type` is a string that can be either `directory` or `file`.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.files.stat('/file.txt', (err, stats) => {
console.log(stats)
})

// {
// hash: 'QmXmJBmnYqXVuicUfn9uDCC8kxCEEzQpsAbeq1iJvLAmVs',
// size: 60,
// cumulativeSize: 118,
// blocks: 1,
// type: 'file'
// }
```

#### `rm`

> Remove a file or directory.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.rm(path, [options, callback])

Where:

- `path` is the path of the object to remove.
- `options` is an optional Object that might contain the following keys:
- `recursive` is a Boolean value to decide whether or not to remove directories recursively.

`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
// To remove a file
ipfs.files.mkdir('/my/beautiful/file.txt', (err) => {
if (err) {
console.error(err)
}
})

// To remove a directory
ipfs.files.mkdir('/my/beautiful/directory', { recursive: true }, (err) => {
if (err) {
console.error(err)
}
})
```

#### `read`

> Read a file.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.read(path, [options, callback])

Where:

- `path` is the path of the object to read.
- `options` is an optional Object that might contain the following keys:
- `offset` is an Integer with the byte offset to begin reading from.
- `count` is an Integer with the maximum number of bytes to read.

`callback` must follow the `function (err, buf) {}` signature, where `err` is an Error if the operation was not successful and `buf` is a Buffer with the contents of `path`.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.files.read('/hello-world', (err, buf) => {
console.log(buf.toString())
})

// Hello, World!
```

#### `write`

> Write to a file.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.write(path, content, [options, callback])

Where:

- `path` is the path of the object to write.
- `content` can be:
- a Buffer instance.
- a Path (caveat: will only work in Node.js).
- `options` is an optional Object that might contain the following keys:
- `offset` is an Integer with the byte offset to begin writing at.
- `create` is a Boolean to indicate to create the file if it doesn't exist.
- `truncate` is a Boolean to indicate if the file should be truncated to size 0 before writing.
- `count` is an Integer with the maximum number of bytes to read.

`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.files.write('/hello-world', Buffer.from('Hello, world!'), (err) => {
console.log(err)
})
```

#### `mv`

> Move files.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.mv([from, to], [callback])

Where:

- `from` is the path of the source object to move.
- `to` is the path of the destination object to move to.

`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.files.mv(['/src-file', '/dst-file'], (err) => {
if (err) {
console.error(err)
}
})
```

#### `flush`

> Flush a given path's data to the disk
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.flush([path, callback])

Where:

- `path` is the path to flush. Default is `/`.

`callback` must follow the `function (err) {}` signature, where `err` is an Error if the operation was not successful.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.files.flush('/', (err) => {
if (err) {
console.error(err)
}
})
```

#### `ls`

> List directories in the local mutable namespace.
##### `Go` **WIP**

##### `JavaScript` - ipfs.files.ls([path, options, callback])

Where:

- `path` is the path to show listing for. Defaults to `/`.
- `options` is an optional Object that might contain the following keys:
- `l` is a Boolean value o use long listing format.

`callback` must follow `function (err, files) {}` signature, where `err` is an error if the operation was not successful. `files` is an array containing Objects that contain the following keys:

- `name` which is the file's name.
- `type` which i the object's type (`directory` or `file`).
- `size` the size of the file in bytes.
- `hash` the hash of the file.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.files.ls('/screenshots', function (err, files) {
files.forEach((file) => {
console.log(file.name)
})
})

// 2018-01-22T18:08:46.775Z.png
// 2018-01-22T18:08:49.184Z.png
```

[examples]: https://github.com/ipfs/interface-ipfs-core/blob/master/src/files.js
[b]: https://www.npmjs.com/package/buffer
[rs]: https://www.npmjs.com/package/readable-stream
3 changes: 1 addition & 2 deletions SPEC/PUBSUB.md
Original file line number Diff line number Diff line change
@@ -101,9 +101,8 @@ A great source of [examples][] can be found in the tests for this API.
##### `Go` **WIP**

##### `JavaScript` - ipfs.pubsub.ls(topic, callback)
##### `JavaScript` - ipfs.pubsub.ls(callback)

- `topic: string`
- `callback: (Error, Array<string>>) => ()` - Calls back with an error or a list of topicCIDs that this peer is subscribed to.

If no `callback` is passed, a promise is returned.
Loading