Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Implement "file ls" #1078

Merged
merged 10 commits into from
Nov 17, 2017
Merged

Implement "file ls" #1078

merged 10 commits into from
Nov 17, 2017

Conversation

richardschneider
Copy link
Contributor

@richardschneider richardschneider commented Nov 16, 2017

Add file ls to both the CLI and HTTP API. CLI docs and API docs.

@daviddias
Copy link
Member

@richardschneider I had understood from IRC that you opted by the direction of not using file ls anymore, did that change?

@richardschneider
Copy link
Contributor Author

It turns out there is just not enough information about the directory. Also, asking for file information is not supported (I think)

http://localhost:5001/api/v0/file/ls?arg=/ipfs/QmRCJXG7HSmprrYwDrK1GctXHgbV7EYpVcJPQPwevoQuqF/test

{
    "Arguments": {
        "/ipfs/QmRCJXG7HSmprrYwDrK1GctXHgbV7EYpVcJPQPwevoQuqF/test": "QmNtpA5TBNqHrKf3cLQ1AiUKXiE4JmUodbG5gXrajg8wdv"
    },
    "Objects": {
        "QmNtpA5TBNqHrKf3cLQ1AiUKXiE4JmUodbG5gXrajg8wdv": {
            "Hash": "QmNtpA5TBNqHrKf3cLQ1AiUKXiE4JmUodbG5gXrajg8wdv",
            "Size": 277,
            "Type": "Directory",
            "Name": "test",
            "Links": [
                {
                    "Hash": "QmTz3oc4gdpRMKP2sdGUPZTAGRngqjsi99BPoztyP53JMM",
                    "Size": 12,
                    "Type": "File",
                    "Name": "bar"
                },
                {
                    "Hash": "QmX1ebVUtfY11ZCpVmqyE5mDoN62SpLd8eLPpg5GGV1ABt",
                    "Size": 114,
                    "Type": "Directory",
                    "Name": "baz"
                },
                {
                    "Hash": "QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6",
                    "Size": 12,
                    "Type": "File",
                    "Name": "foo"
                }
            ]
        }
    }
}

http://localhost:5001/api/v0/ls?arg=/ipfs/QmRCJXG7HSmprrYwDrK1GctXHgbV7EYpVcJPQPwevoQuqF/test

{
    "Objects": [
        {
            "Hash": "/ipfs/QmRCJXG7HSmprrYwDrK1GctXHgbV7EYpVcJPQPwevoQuqF/test",
            "Links": [
                {
                    "Name": "test",
                    "Hash": "QmNtpA5TBNqHrKf3cLQ1AiUKXiE4JmUodbG5gXrajg8wdv",
                    "Size": 277,
                    "Type": 1
                }
            ]
        }
    ]
}

@richardschneider
Copy link
Contributor Author

richardschneider commented Nov 16, 2017

I've raised #1079, about the subfolder issue. However, to summarise why I can't use ipfs ls

  • Doesn't provide information about the specified directory, only is contents
  • Doesn't accept a file. I need it for fstat information

So instead of breaking interfaces, I just implemented an existing interface.

PS: This got mounting IPFS on windows with js-ipfs working 🕺

@richardschneider
Copy link
Contributor Author

@diasdavid LGTM

@daviddias daviddias merged commit 6db3fb8 into master Nov 17, 2017
@daviddias daviddias deleted the file-ls branch November 17, 2017 09:55
@ghost ghost removed the status/in-progress In progress label Nov 17, 2017
MicrowaveDev pushed a commit to galtproject/js-ipfs that referenced this pull request May 22, 2020
Adds a method called `ipfs._addAsyncIterator`, prefixed with an
underscore to mark it as sort of unofficial (though it's what
`ipfs.add` will become once the async iterator migration is complete)
and we don't want to implement symmetrical `ipfs.catAsyncIterator`
etc methods, or at least not yet.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants