summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Michaelis <gitter@liftm.de>2020-07-09 20:41:11 +0900
committerJulius Michaelis <gitter@liftm.de>2020-07-09 20:52:33 +0900
commit7a386ef41c5666dc98e75b5cec60f9f48e4450ae (patch)
tree52ca465ebd24d537ccf7fc3ba782137c98263f40
parenta162e2cbc3dd0898211056154af57e6ec58d7808 (diff)
add ipfs files stat --with-local
-rw-r--r--ipfs-api/examples/mfs.rs4
-rw-r--r--ipfs-api/src/client/internal.rs6
-rw-r--r--ipfs-api/src/request/files.rs3
-rw-r--r--ipfs-api/src/response/files.rs5
4 files changed, 13 insertions, 5 deletions
diff --git a/ipfs-api/examples/mfs.rs b/ipfs-api/examples/mfs.rs
index b53935c..2b20111 100644
--- a/ipfs-api/examples/mfs.rs
+++ b/ipfs-api/examples/mfs.rs
@@ -47,7 +47,7 @@ async fn main() {
eprintln!("getting status of /test/does...");
eprintln!();
- match client.files_stat("/test/does").await {
+ match client.files_stat("/test/does", false).await {
Ok(stat) => print_stat(stat),
Err(e) => {
eprintln!("error getting status of /test/does: {}", e);
@@ -68,7 +68,7 @@ async fn main() {
eprintln!("getting status of /test/mfs.rs...");
eprintln!();
- match client.files_stat("/test/mfs.rs").await {
+ match client.files_stat("/test/mfs.rs", false).await {
Ok(stat) => print_stat(stat),
Err(e) => {
eprintln!("error getting status of /test/mfs.rs: {}", e);
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs
index f317fe8..8eaf595 100644
--- a/ipfs-api/src/client/internal.rs
+++ b/ipfs-api/src/client/internal.rs
@@ -1210,12 +1210,12 @@ impl IpfsClient {
/// use ipfs_api::IpfsClient;
///
/// let client = IpfsClient::default();
- /// let res = client.files_stat("/test/file.json");
+ /// let res = client.files_stat("/test/file.json", false);
/// ```
///
#[inline]
- pub async fn files_stat(&self, path: &str) -> Result<response::FilesStatResponse, Error> {
- self.request(request::FilesStat { path }, None).await
+ pub async fn files_stat(&self, path: &str, with_local: bool) -> Result<response::FilesStatResponse, Error> {
+ self.request(request::FilesStat { path, with_local }, None).await
}
/// Write to a mutable file in the filesystem.
diff --git a/ipfs-api/src/request/files.rs b/ipfs-api/src/request/files.rs
index e70e04b..b4b148f 100644
--- a/ipfs-api/src/request/files.rs
+++ b/ipfs-api/src/request/files.rs
@@ -112,6 +112,9 @@ impl<'a> ApiRequest for FilesRm<'a> {
pub struct FilesStat<'a> {
#[serde(rename = "arg")]
pub path: &'a str,
+
+ #[serde(rename = "with-local")]
+ pub with_local: bool,
}
impl<'a> ApiRequest for FilesStat<'a> {
diff --git a/ipfs-api/src/response/files.rs b/ipfs-api/src/response/files.rs
index 76dc4a1..f27be1f 100644
--- a/ipfs-api/src/response/files.rs
+++ b/ipfs-api/src/response/files.rs
@@ -50,6 +50,11 @@ pub struct FilesStatResponse {
#[serde(rename = "Type")]
pub typ: String,
+
+ #[serde(default)]
+ pub size_local: Option<u64>,
+ #[serde(default)]
+ pub local: Option<bool>,
}
pub type FilesWriteResponse = ();