diff options
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/build.rs | 34 | ||||
-rw-r--r-- | src/commands/find_artifact.rs | 34 | ||||
-rw-r--r-- | src/commands/release.rs | 9 |
3 files changed, 45 insertions, 32 deletions
diff --git a/src/commands/build.rs b/src/commands/build.rs index 05fb0d6..1044896 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -151,20 +151,24 @@ pub async fn build( .get(0) .ok_or_else(|| anyhow!("Found no package."))?; - let release_dir = { - let bar_release_loading = progressbars.bar(); - bar_release_loading.set_length(max_packages); - - let p = config.releases_directory(); - debug!("Loading release directory: {}", p.display()); - let r = ReleaseStore::load(StoreRoot::new(p.clone())?, bar_release_loading.clone()); - if r.is_ok() { - bar_release_loading.finish_with_message("Loaded releases successfully"); - } else { - bar_release_loading.finish_with_message("Failed to load releases"); - } - r.map(RwLock::new).map(Arc::new)? - }; + let release_stores = config + .release_stores() + .iter() + .map(|storename| { + let bar_release_loading = progressbars.bar(); + bar_release_loading.set_length(max_packages); + + let p = config.releases_directory().join(storename); + debug!("Loading release directory: {}", p.display()); + let r = ReleaseStore::load(StoreRoot::new(p)?, bar_release_loading.clone()); + if r.is_ok() { + bar_release_loading.finish_with_message("Loaded releases successfully"); + } else { + bar_release_loading.finish_with_message("Failed to load releases"); + } + r.map(Arc::new) + }) + .collect::<Result<Vec<_>>>()?; let (staging_store, staging_dir, submit_id) = { let bar_staging_loading = progressbars.bar(); @@ -325,7 +329,7 @@ pub async fn build( .progress_generator(progressbars) .endpoint_config(endpoint_configurations) .staging_store(staging_store) - .release_store(release_dir) + .release_stores(release_stores) .database(database_connection.clone()) .source_cache(source_cache) .submit(submit) diff --git a/src/commands/find_artifact.rs b/src/commands/find_artifact.rs index bf48130..93b332b 100644 --- a/src/commands/find_artifact.rs +++ b/src/commands/find_artifact.rs @@ -50,20 +50,26 @@ pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progres log::debug!("Finding artifacts for '{:?}' '{:?}'", package_name_regex, package_version_constraint); - let release_store = { - let bar_release_loading = progressbars.bar(); - bar_release_loading.set_length(max_packages); + let release_stores = config + .release_stores() + .iter() + .map(|storename| { + let bar_release_loading = progressbars.bar(); + bar_release_loading.set_length(max_packages); + + let p = config.releases_directory().join(storename); + debug!("Loading release directory: {}", p.display()); + let r = ReleaseStore::load(StoreRoot::new(p)?, bar_release_loading.clone()); + if r.is_ok() { + bar_release_loading.finish_with_message("Loaded releases successfully"); + } else { + bar_release_loading.finish_with_message("Failed to load releases"); + } + + r.map(Arc::new) + }) + .collect::<Result<Vec<_>>>()?; - let p = config.releases_directory(); - debug!("Loading release directory: {}", p.display()); - let r = ReleaseStore::load(StoreRoot::new(p.clone())?, bar_release_loading.clone()); - if r.is_ok() { - bar_release_loading.finish_with_message("Loaded releases successfully"); - } else { - bar_release_loading.finish_with_message("Failed to load releases"); - } - r? - }; let staging_store = if let Some(p) = matches.value_of("staging_dir").map(PathBuf::from) { let bar_staging_loading = progressbars.bar(); bar_staging_loading.set_length(max_packages); @@ -96,7 +102,7 @@ pub async fn find_artifact(matches: &ArgMatches, config: &Configuration, progres .inspect(|pkg| trace!("Found package: {:?}", pkg)) .map(|pkg| { let script_filter = !matches.is_present("no_script_filter"); - let pathes = crate::db::find_artifacts(database.clone(), config, &pkg, &release_store, staging_store.as_ref(), &env_filter, script_filter)?; + let pathes = crate::db::find_artifacts(database.clone(), config, &pkg, &release_stores, staging_store.as_ref(), &env_filter, script_filter)?; pathes.iter() .map(|tpl| (tpl.0.joined(), tpl.1)) diff --git a/src/commands/release.rs b/src/commands/release.rs index 7dde913..51ecd89 100644 --- a/src/commands/release.rs +++ b/src/commands/release.rs @@ -28,6 +28,7 @@ pub async fn release( config: &Configuration, matches: &ArgMatches, ) -> Result<()> { + let release_store_name = matches.value_of("release_store_name").unwrap(); // safe by clap if !(config.releases_directory().exists() && config.releases_directory().is_dir()) { return Err(anyhow!( "Release directory does not exist or does not point to directory: {}", @@ -103,7 +104,7 @@ pub async fn release( .filter_map(|art| { art.path_buf() .parent() - .map(|p| config.releases_directory().join(p)) + .map(|p| config.releases_directory().join(release_store_name).join(p)) }) .map(|p| async { debug!("mkdir {:?}", p); @@ -115,11 +116,13 @@ pub async fn release( let staging_base: &PathBuf = &config.staging_directory().join(submit.uuid.to_string()); + let release_store = crate::db::models::ReleaseStore::create(&conn, release_store_name)?; + let now = chrono::offset::Local::now().naive_local(); arts.into_iter() .map(|art| async move { let art_path = staging_base.join(&art.path); - let dest_path = config.releases_directory().join(&art.path); + let dest_path = config.releases_directory().join(release_store_name).join(&art.path); debug!( "Trying to release {} to {}", art_path.display(), @@ -147,7 +150,7 @@ pub async fn release( .into_iter() .try_for_each(|art| { debug!("Updating {:?} to set released = true", art); - let rel = crate::db::models::Release::create(&conn, &art, &now)?; + let rel = crate::db::models::Release::create(&conn, &art, &now, &release_store)?; debug!("Release object = {:?}", rel); Ok(()) }) |