chore: cargo fmt

This commit is contained in:
Joonas Koivunen 2020-06-17 12:19:55 +03:00
parent 1d50a5195c
commit 6be2556341
4 changed files with 22 additions and 18 deletions

View File

@ -245,8 +245,8 @@ mod tests {
use ipfs::{Block, Ipfs, IpfsTypes};
use libipld::cid::Cid;
use multihash::Sha2_256;
use std::path::PathBuf;
use std::convert::TryFrom;
use std::path::PathBuf;
// Entry we'll use in expectations
#[derive(Debug, PartialEq, Eq)]
@ -294,7 +294,6 @@ mod tests {
#[tokio::test]
async fn very_long_file_and_symlink_names() {
let options = ipfs::IpfsOptions::inmemory_with_generated_keys(false);
let (ipfs, _) = ipfs::UninitializedIpfs::new(options)
.await
@ -356,7 +355,6 @@ mod tests {
#[tokio::test]
async fn get_multiblock_file() {
let options = ipfs::IpfsOptions::inmemory_with_generated_keys(false);
let (ipfs, _) = ipfs::UninitializedIpfs::new(options)
.await
@ -391,9 +389,11 @@ mod tests {
let found = get_archive_entries(response.body());
let expected = vec![
Entry::File("QmRJHYTNvC3hmd9gJQARxLR1QMEincccBV53bBw524yyq6".into(), 7, b"foobar\n".to_vec()),
];
let expected = vec![Entry::File(
"QmRJHYTNvC3hmd9gJQARxLR1QMEincccBV53bBw524yyq6".into(),
7,
b"foobar\n".to_vec(),
)];
assert_eq!(found, expected);
}
@ -402,15 +402,20 @@ mod tests {
let mut cursor = std::io::Cursor::new(bytes.as_ref());
let mut archive = tar::Archive::new(&mut cursor);
archive.entries()
.and_then(|entries|
archive
.entries()
.and_then(|entries| {
entries
.map(|res| res.and_then(Entry::try_from))
.collect::<Result<Vec<Entry>, _>>()
).unwrap()
})
.unwrap()
}
fn put_all_blocks<'a, T: IpfsTypes>(ipfs: &'a Ipfs<T>, blocks: &'a [&'a [u8]]) -> impl std::future::Future<Output = Result<Vec<Cid>, ipfs::Error>> + 'a {
fn put_all_blocks<'a, T: IpfsTypes>(
ipfs: &'a Ipfs<T>,
blocks: &'a [&'a [u8]],
) -> impl std::future::Future<Output = Result<Vec<Cid>, ipfs::Error>> + 'a {
let mut inorder = FuturesOrdered::new();
for block in blocks {
inorder.push(put_block(&ipfs, block));

View File

@ -72,7 +72,6 @@ fn walk(blocks: ShardedBlockStore, start: &Cid) -> Result<(), Error> {
// items.
visit = match walker.continue_walk(&buf, &mut cache)? {
ContinuedWalk::File(segment, item) => {
let entry = item.as_entry();
let total_size = entry.total_file_size().expect("all files have total size");
// metadata is picked up from the root file and carried until the last block
@ -84,7 +83,6 @@ fn walk(blocks: ShardedBlockStore, start: &Cid) -> Result<(), Error> {
}
if segment.is_last() {
let path = entry.path();
let mode = metadata.mode().unwrap_or(0o0644) & 0o7777;
let (seconds, _) = metadata.mtime().unwrap_or((0, 0));
@ -112,16 +110,17 @@ fn walk(blocks: ShardedBlockStore, start: &Cid) -> Result<(), Error> {
}
ContinuedWalk::Symlink(bytes, item) => {
let entry = item.as_entry();
let metadata = entry
.metadata()
.expect("symlink must have metadata");
let metadata = entry.metadata().expect("symlink must have metadata");
let path = entry.path();
let target = Path::new(std::str::from_utf8(bytes).unwrap());
let mode = metadata.mode().unwrap_or(0o0755) & 0o7777;
let (seconds, _) = metadata.mtime().unwrap_or((0, 0));
println!("s {:o} {:>12} {:>16} {:?} -> {:?}", mode, seconds, "-", path, target);
println!(
"s {:o} {:>12} {:>16} {:?} -> {:?}",
mode, seconds, "-", path, target
);
item.into_inner()
}

View File

@ -179,8 +179,8 @@ impl<'a> UnwrapBorrowedExt<'a> for Option<Cow<'a, [u8]>> {
#[cfg(test)]
pub(crate) mod tests {
use super::{reader::*, visit::*, UnwrapBorrowedExt};
use hex_literal::hex;
use crate::test_support::FakeBlockstore;
use hex_literal::hex;
const CONTENT_FILE: &[u8] = &hex!("0a0d08021207636f6e74656e741807");

View File

@ -1,7 +1,7 @@
use cid::Cid;
use hex_literal::hex;
use std::collections::HashMap;
use std::convert::TryFrom;
use hex_literal::hex;
#[derive(Default)]
pub struct FakeBlockstore {