mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
Have app send download analytics meta (#5954)
* wip: add download reasons to app * update how download meta is gathered * cargo fmt * prepr frontend
This commit is contained in:
@@ -6,9 +6,12 @@ use crate::pack::install_from::{
|
||||
EnvType, PackFile, PackFileHash, set_profile_information,
|
||||
};
|
||||
use crate::state::{
|
||||
CacheBehaviour, CachedEntry, ProfileInstallStage, SideType, cache_file_hash,
|
||||
CacheBehaviour, CachedEntry, Profile, ProfileInstallStage, SideType,
|
||||
cache_file_hash,
|
||||
};
|
||||
use crate::util::fetch::{
|
||||
DownloadMeta, DownloadReason, fetch_mirrors, sha1_async, write,
|
||||
};
|
||||
use crate::util::fetch::{fetch_mirrors, sha1_async, write};
|
||||
use crate::util::io;
|
||||
use crate::{State, profile};
|
||||
use async_zip::base::read::seek::ZipFileReader;
|
||||
@@ -207,6 +210,22 @@ pub async fn install_zipped_mrpack_files(
|
||||
)
|
||||
.await?;
|
||||
|
||||
let profile =
|
||||
Profile::get(&profile_path, &state.pool)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::UnmanagedProfileError(
|
||||
profile_path.to_string(),
|
||||
)
|
||||
.as_error()
|
||||
})?;
|
||||
|
||||
let download_meta = DownloadMeta {
|
||||
reason: DownloadReason::Modpack,
|
||||
game_version: profile.game_version.clone(),
|
||||
loader: profile.loader.as_str().to_string(),
|
||||
};
|
||||
|
||||
let num_files = pack.files.len();
|
||||
loading_try_for_each_concurrent(
|
||||
futures::stream::iter(pack.files.into_iter())
|
||||
@@ -218,6 +237,7 @@ pub async fn install_zipped_mrpack_files(
|
||||
None,
|
||||
|project| {
|
||||
let profile_path = profile_path.clone();
|
||||
let download_meta = download_meta.clone();
|
||||
async move {
|
||||
//TODO: Future update: prompt user for optional files in a modpack
|
||||
if let Some(env) = project.env
|
||||
@@ -235,6 +255,7 @@ pub async fn install_zipped_mrpack_files(
|
||||
.map(|x| &**x)
|
||||
.collect::<Vec<&str>>(),
|
||||
project.hashes.get(&PackFileHash::Sha1).map(|x| &**x),
|
||||
Some(&download_meta),
|
||||
&state.fetch_semaphore,
|
||||
&state.pool,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user