Skip to content

Commit f4d7c00

Browse files
committed
upgrade dependencies
1 parent 03db012 commit f4d7c00

File tree

8 files changed

+706
-471
lines changed

8 files changed

+706
-471
lines changed

Cargo.lock

+675-429
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-lfs-ipfs-cli/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "git-lfs-ipfs-cli"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
authors = ["Sameer Puri <crates@purisa.me>"]
5-
edition = "2018"
5+
edition = "2021"
66
description = "A git-lfs custom transfer & extension that makes it easy to store large files with IPFS"
77
readme = "../README.md"
88
license = "MIT OR Apache-2.0"
@@ -18,8 +18,8 @@ serde_json = "1"
1818
cid = { version = "0", default-features = false, features = ["std"] }
1919
git-lfs-spec = { path = "../git-lfs-spec", version = "0" }
2020
structopt = "0.3"
21-
multihash = { version = "0.14", features = ["sha2", "multihash-impl"], default-features = false }
22-
ipfs-api = { version = "0.12", features = ["with-hyper-rustls"], default-features = false, git = "https://github.com/ferristseng/rust-ipfs-api.git" }
21+
multihash = { version = "0.18", features = ["sha2", "multihash-impl"], default-features = false }
22+
ipfs-api-backend-hyper = { version = "0.6", features = ["with-hyper-rustls"] }
2323
hex = "0"
2424
serde = "1"
2525
futures = "0.3"

git-lfs-ipfs-cli/src/clean.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
use std::io::Read;
2+
13
use anyhow::Result;
24
use futures::StreamExt;
3-
use ipfs_api::{response::AddResponse, IpfsApi};
4-
use std::io::Read;
5+
use ipfs_api_backend_hyper::{response::AddResponse, IpfsApi};
56
use tokio::io::{AsyncWrite, AsyncWriteExt};
67

78
/// Replace file contents with the raw IPFS block contents.
@@ -15,7 +16,7 @@ use tokio::io::{AsyncWrite, AsyncWriteExt};
1516
/// <https://github.com/git-lfs/git-lfs/blob/main/docs/extensions.md#clean>
1617
pub async fn clean<E: 'static + Send + Sync + std::error::Error>(
1718
client: impl IpfsApi<Error = E>,
18-
input: impl Read + Send + Sync + 'static,
19+
input: impl Read + Send + Sync + Unpin + 'static,
1920
mut output: impl AsyncWrite + AsyncWriteExt + Unpin,
2021
) -> Result<()> {
2122
let AddResponse { hash, .. } = client.add(input).await?;

git-lfs-ipfs-cli/src/ipfs.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use hyper::client::HttpConnector;
3-
use ipfs_api::IpfsClient;
4-
use multihash::{Code, MultihashDigest, Sha2Digest, U32};
3+
use ipfs_api_backend_hyper::IpfsClient;
4+
use multihash::{Code, MultihashDigest};
55

66
/// Assuming that the sha256 hash is for a Qmhash
77
pub fn sha256_to_cid(sha256_str: &str) -> Result<cid::Cid> {
@@ -12,9 +12,7 @@ pub fn sha256_to_cid(sha256_str: &str) -> Result<cid::Cid> {
1212
raw_digest.len()
1313
))
1414
} else {
15-
let mut digest = Sha2Digest::<U32>::default();
16-
digest.as_mut().copy_from_slice(&raw_digest);
17-
Ok(cid::Cid::new_v0(Code::multihash_from_digest(&digest))?)
15+
Ok(cid::Cid::new_v0(Code::Sha2_256.wrap(&raw_digest)?)?)
1816
}
1917
}
2018

git-lfs-ipfs-cli/src/smudge.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use anyhow::Result;
22
use cid::Cid;
33
use futures::stream::StreamExt;
4-
use ipfs_api::IpfsApi;
5-
use multihash::{Code, MultihashDigest, Sha2Digest, Sha2_256, StatefulHasher, U32};
4+
use ipfs_api_backend_hyper::IpfsApi;
5+
use multihash::{Code, Hasher, Multihash, MultihashDigest, Sha2_256};
66
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
77

88
/// Verbatim from IPFS cli docs:
@@ -14,9 +14,7 @@ const CHUNKER_FIXED_BLOCK_SIZE: usize = 256 * 1024;
1414

1515
const BUFFER_SIZE: usize = CHUNKER_FIXED_BLOCK_SIZE / 256;
1616

17-
async fn sha256_hash_of_raw_block(
18-
mut input: impl AsyncRead + AsyncReadExt + Unpin,
19-
) -> Result<Sha2Digest<U32>> {
17+
async fn sha256_hash_of_raw_block(mut input: impl AsyncRead + Unpin) -> Result<Multihash> {
2018
let mut buffer = [0u8; BUFFER_SIZE];
2119
let mut hasher = Sha2_256::default();
2220
loop {
@@ -26,13 +24,12 @@ async fn sha256_hash_of_raw_block(
2624
}
2725
hasher.update(&buffer[..bytes_read]);
2826
}
29-
Ok(hasher.finalize())
27+
Ok(Code::Sha2_256.wrap(hasher.finalize())?)
3028
}
3129

32-
async fn cid_of_raw_block(input: impl AsyncRead + AsyncReadExt + Unpin) -> Result<Cid> {
30+
async fn cid_of_raw_block(input: impl AsyncRead + Unpin) -> Result<Cid> {
3331
let sha256_hash = sha256_hash_of_raw_block(input).await?;
34-
let hash = Code::multihash_from_digest(&sha256_hash);
35-
Ok(Cid::new_v0(hash.into()).unwrap())
32+
Ok(Cid::new_v0(sha256_hash).unwrap())
3633
}
3734

3835
/// Convert a file's raw IPFS block back into the file itself
@@ -43,8 +40,8 @@ async fn cid_of_raw_block(input: impl AsyncRead + AsyncReadExt + Unpin) -> Resul
4340
/// <https://github.com/git-lfs/git-lfs/blob/main/docs/extensions.md#smudge>
4441
pub async fn smudge<E: 'static + Send + Sync + std::error::Error>(
4542
client: impl IpfsApi<Error = E>,
46-
input: impl AsyncRead + AsyncReadExt + Unpin,
47-
mut output: impl AsyncWrite + AsyncWriteExt + Unpin,
43+
input: impl AsyncRead + Unpin,
44+
mut output: impl AsyncWrite + Unpin,
4845
) -> Result<()> {
4946
let cid = cid_of_raw_block(input).await?;
5047
let mut stream = client.cat(&format!("/ipfs/{}", cid));
@@ -70,7 +67,7 @@ mod tests {
7067
#[tokio::test]
7168
async fn sha256_hash_of_raw_block_returns_expected_hash() {
7269
assert_eq!(
73-
sha256_hash_of_raw_block(RAW_BLOCK).await.unwrap().as_ref(),
70+
sha256_hash_of_raw_block(RAW_BLOCK).await.unwrap().digest(),
7471
hex::decode(SHA256_HASH).unwrap()
7572
);
7673
}

git-lfs-ipfs-cli/src/transfer.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use anyhow::{Context, Result};
22
use futures::{Stream, StreamExt};
3-
use ipfs_api::IpfsApi;
3+
use ipfs_api_backend_hyper::IpfsApi;
44
use std::{io::Write, path::Path};
55
use tokio::io::{AsyncBufRead, AsyncBufReadExt};
66

77
use git_lfs_spec::transfer::custom::{self, Complete, Error, Event, Operation, Progress};
88

9-
pub fn read_events(
10-
input: impl AsyncBufRead + AsyncBufReadExt + Unpin,
11-
) -> impl Stream<Item = Result<Event>> {
9+
pub fn read_events(input: impl AsyncBufRead + Unpin) -> impl Stream<Item = Result<Event>> {
1210
async_stream::stream! {
1311
let mut lines = input.lines();
1412
while let Some(line) = lines.next_line().await? {
@@ -149,7 +147,7 @@ mod tests {
149147
async fn transfer_handles_events_as_expected_for_download() {
150148
let temp_dir = tempdir().unwrap();
151149

152-
let expected_output_path = temp_dir.path().join(&OID);
150+
let expected_output_path = temp_dir.path().join(OID);
153151

154152
let client = client();
155153
let input_events = [

git-lfs-spec/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "git-lfs-spec"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
authors = ["Sameer Puri <crates@purisa.me>"]
5-
edition = "2018"
5+
edition = "2021"
66
description = "Rust types for Git LFS"
77
readme = "../README.md"
88
license = "MIT OR Apache-2.0"

git-lfs-spec/src/spec/batch.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ pub enum Operation {
3333
}
3434

3535
/// https://github.com/git-lfs/git-lfs/blob/master/docs/api/basic-transfers.md#basic-transfer-api
36-
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize)]
36+
#[derive(PartialEq, Eq, Debug, Deserialize, Serialize, Default)]
3737
#[serde(rename_all = "lowercase")]
3838
pub enum Transfer {
39+
#[default]
3940
Basic,
4041
Custom,
4142
}
@@ -46,12 +47,6 @@ impl Transfer {
4647
}
4748
}
4849

49-
impl Default for Transfer {
50-
fn default() -> Self {
51-
Transfer::Basic
52-
}
53-
}
54-
5550
/// https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md#ref-property
5651
#[derive(PartialEq, Eq, Debug, Deserialize)]
5752
pub struct Ref {
@@ -67,7 +62,7 @@ pub enum ObjectResponse {
6762
object: Object,
6863
#[serde(skip_serializing_if = "Option::is_none")]
6964
authenticated: Option<bool>,
70-
actions: Actions,
65+
actions: Box<Actions>,
7166
},
7267
Error {
7368
#[serde(flatten)]
@@ -81,7 +76,7 @@ impl ObjectResponse {
8176
ObjectResponse::Success {
8277
object,
8378
authenticated: None,
84-
actions,
79+
actions: Box::new(actions),
8580
}
8681
}
8782

@@ -223,7 +218,7 @@ mod test {
223218
size: 123,
224219
},
225220
authenticated: Some(true),
226-
actions: Actions::Download {
221+
actions: Box::new(Actions::Download {
227222
download: Action {
228223
href: Url::parse("https://some-download.com").unwrap(),
229224
header: Some(
@@ -237,7 +232,7 @@ mod test {
237232
.unwrap()
238233
.into()
239234
}
240-
}
235+
})
241236
}],
242237
})
243238
.unwrap(),

0 commit comments

Comments
 (0)