Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download compressed gz image from remote source #41

Merged
merged 5 commits into from Dec 16, 2022
Merged

Conversation

Razaloc
Copy link
Contributor

@Razaloc Razaloc commented Oct 24, 2022

Accept url arguments for remote image download and copy.
Implements async support for use of reqwest. Bmap file is searched as in
local option in the current file with same name and the extension ".bmap"
Closes: #9
Closes: #46
Closes: #8

Signed-off-by: Rafael Garcia Ruiz rafael.garcia@collabora.com

@Razaloc Razaloc changed the title Download image from remote image Download image from remote source Oct 24, 2022
@Razaloc Razaloc changed the title Download image from remote source Download compressed gz image from remote source Oct 24, 2022
@Razaloc Razaloc force-pushed the wip/rafaelgarrui/async branch 2 times, most recently from b4bdc49 to 2c88656 Compare October 24, 2022 17:40
@Razaloc
Copy link
Contributor Author

Razaloc commented Oct 24, 2022

Takes some of the intended changes of #34 applying review comments.

bmap-rs/src/main.rs Outdated Show resolved Hide resolved
@Razaloc Razaloc force-pushed the wip/rafaelgarrui/async branch 5 times, most recently from bb61d3b to eec84da Compare October 26, 2022 15:32
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
@Razaloc Razaloc force-pushed the wip/rafaelgarrui/async branch 2 times, most recently from c2a8337 to 1d8a0f8 Compare October 27, 2022 18:00
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
@Razaloc Razaloc force-pushed the wip/rafaelgarrui/async branch 5 times, most recently from 05585e2 to 60800ad Compare October 28, 2022 15:18
@Razaloc
Copy link
Contributor Author

Razaloc commented Oct 28, 2022

main.rs new code is now extracted into copy_async. Instead of branching every sync/async action, now we have two branches of execution starting at the main function, depending on the input:

async fn main() -> Result<()> {
    let opts = Opts::parse();

    match opts.command {
        Command::Copy(c) => match Url::parse(c.image.to_str().unwrap()) {
            Ok(_) => copy_async(c).await,
            Err(_) => copy(c),
        },
    }
}

The idea is to make the code clearer and more readable, and also leave the copy intact since we haven't actually touch it.

bmap-rs/src/main.rs Outdated Show resolved Hide resolved
@Razaloc Razaloc force-pushed the wip/rafaelgarrui/async branch 2 times, most recently from 5990e31 to 6726fa1 Compare October 28, 2022 15:40
@Razaloc
Copy link
Contributor Author

Razaloc commented Oct 28, 2022

main.rs new code is now extracted into copy_remote_input. Instead of branching every sync/async action, now we have two branches of execution starting at the copy function, depending on the input:

async fn copy(c: Copy) -> Result<()> {
    match Url::parse(c.image.to_str().unwrap()) {
        Ok(_) => copy_remote_input(c).await,
        Err(_) => copy_local_input(c),
    }
}

The idea is to make the code clearer and more readable, and also leave the copy_local_input inside intact since we haven't actually touch it.

@obbardc
Copy link
Collaborator

obbardc commented Oct 31, 2022

@Razaloc Can you resolve the merge conflicts ?

bmap-rs/src/main.rs Outdated Show resolved Hide resolved
@Razaloc Razaloc force-pushed the wip/rafaelgarrui/async branch 7 times, most recently from c80967c to 8691dc5 Compare November 18, 2022 16:33
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
bmap/src/discarder.rs Outdated Show resolved Hide resolved
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
@Razaloc Razaloc force-pushed the wip/rafaelgarrui/async branch 3 times, most recently from b8fe715 to 04885a0 Compare December 1, 2022 10:13
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
bmap-rs/src/main.rs Outdated Show resolved Hide resolved
@Razaloc Razaloc force-pushed the wip/rafaelgarrui/async branch 3 times, most recently from 77d760c to 6f11483 Compare December 13, 2022 13:32
Prepare bmap copy from remote source. Create an asynchronous alternative pipeline
for asynchronous copy data downloaded from remote source. We want the data to be
streamed into the copying function instead of be fully downloaded before the copy
start, shortening the duration of the overall process.

Signed-off-by: Rafael Garcia Ruiz <rafael.garcia@collabora.com>
Change the use of clap from 'derive' to 'builder' mode. The goal is to allow
Copy.image to be an enum holding a PathBuf or an Url, allowing Url inputs for
the copy function. This way, we only parse the input value once.

Signed-off-by: Rafael Garcia Ruiz <rafael.garcia@collabora.com>
The current copy function and the future copy_remote_input function will share
a lot of code. We are trying to reduce that duplication, extracting parts and
creating setup_progress_bar and setup_output.

Signed-off-by: Rafael Garcia Ruiz <rafael.garcia@collabora.com>
Accept Url arguments for remote image download and copy. Implements async support
for use of reqwest. Bmap file is searched as in local option in the current file
with same name and the extension ".bmap"

Signed-off-by: Rafael Garcia Ruiz <rafael.garcia@collabora.com>
When downloading the image from a remote source, the bmap will also be searched
remotely and downloaded. The bmap url will be the same as image url, but replacing
the final extension with ".bmap".

Signed-off-by: Rafael Garcia Ruiz <rafael.garcia@collabora.com>
@obbardc
Copy link
Collaborator

obbardc commented Dec 16, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Dec 16, 2022

Build succeeded:

@bors bors bot merged commit a588fa7 into main Dec 16, 2022
@bors bors bot deleted the wip/rafaelgarrui/async branch December 16, 2022 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants