Properly flush stdout while uploading
This commit is contained in:
parent
0530bf42f6
commit
4dc5ffa936
|
@ -76,6 +76,7 @@ fn create(server: &str, args: CreateArgs) {
|
||||||
};
|
};
|
||||||
let index_url = files.into_iter()
|
let index_url = files.into_iter()
|
||||||
.inspect(|(path, _)| print!("\x1b[36m{}\x1b[0m\n\x1b[37m├─\x1b[0m Reading... ", path.display()))
|
.inspect(|(path, _)| print!("\x1b[36m{}\x1b[0m\n\x1b[37m├─\x1b[0m Reading... ", path.display()))
|
||||||
|
.inspect(|_| drop(stdout().flush()))
|
||||||
.map(|(path, mut file)|
|
.map(|(path, mut file)|
|
||||||
(|| {
|
(|| {
|
||||||
let mut buff = Vec::with_capacity(file.metadata()?.len() as usize);
|
let mut buff = Vec::with_capacity(file.metadata()?.len() as usize);
|
||||||
|
@ -84,12 +85,14 @@ fn create(server: &str, args: CreateArgs) {
|
||||||
})().map_err(|e| AviaryError::StreamReadError(path.to_owned(), e))
|
})().map_err(|e| AviaryError::StreamReadError(path.to_owned(), e))
|
||||||
)
|
)
|
||||||
.inspect(|r| if r.is_ok() { print!("\x1b[32mDone!\n\x1b[37m├─\x1b[0m Thumbnailing... ") })
|
.inspect(|r| if r.is_ok() { print!("\x1b[32mDone!\n\x1b[37m├─\x1b[0m Thumbnailing... ") })
|
||||||
|
.inspect(|_| drop(stdout().flush()))
|
||||||
.map(|r| r.and_then(|(path, raw_dat)| {
|
.map(|r| r.and_then(|(path, raw_dat)| {
|
||||||
let (thumbnail, blurhash) = thumbnailing::thumbnail(&raw_dat)
|
let (thumbnail, blurhash) = thumbnailing::thumbnail(&raw_dat)
|
||||||
.map_err(|_| AviaryError::ImageFormatError(path.to_owned()))?;
|
.map_err(|_| AviaryError::ImageFormatError(path.to_owned()))?;
|
||||||
Ok((raw_dat, thumbnail, blurhash))
|
Ok((raw_dat, thumbnail, blurhash))
|
||||||
}))
|
}))
|
||||||
.inspect(|r| if r.is_ok() { print!("\x1b[32mDone!\n\x1b[37m├─\x1b[0m Encrypting... ")})
|
.inspect(|r| if r.is_ok() { print!("\x1b[32mDone!\n\x1b[37m├─\x1b[0m Encrypting... ")})
|
||||||
|
.inspect(|_| drop(stdout().flush()))
|
||||||
.map_ok(|(raw_dat, thumbnail, blurhash)| {
|
.map_ok(|(raw_dat, thumbnail, blurhash)| {
|
||||||
let key = crypto::make_key();
|
let key = crypto::make_key();
|
||||||
(
|
(
|
||||||
|
@ -100,6 +103,7 @@ fn create(server: &str, args: CreateArgs) {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.inspect(|r| if r.is_ok() { print!("\x1b[32mDone!\n\x1b[37m└─\x1b[0m Uploading... ")})
|
.inspect(|r| if r.is_ok() { print!("\x1b[32mDone!\n\x1b[37m└─\x1b[0m Uploading... ")})
|
||||||
|
.inspect(|_| drop(stdout().flush()))
|
||||||
.map(|r| r.and_then(|(key, full_img, thumb, blurhash)|
|
.map(|r| r.and_then(|(key, full_img, thumb, blurhash)|
|
||||||
upload::put_data(&agent, &*full_server, &thumb)
|
upload::put_data(&agent, &*full_server, &thumb)
|
||||||
.and_then(|thumb_url|
|
.and_then(|thumb_url|
|
||||||
|
|
Loading…
Reference in a new issue