🐛 fix: scrap old managed package api (generate_contexts was a bad idea lol), am going to work on feat/package_api
Signed-off-by: Pauline <git@ethanlibs.co>
This commit is contained in:
parent
85bbf0347c
commit
b0e82cc8ec
2 changed files with 4 additions and 57 deletions
|
|
@ -249,7 +249,7 @@ export interface PlausibleMonitorProps {
|
|||
}
|
||||
|
||||
/**
|
||||
* Submits a Plausible Analytics `pageview` event with a hook.
|
||||
* Submits a Plausible Analytics `'pageview'` event with a hook.
|
||||
*
|
||||
* This should watch the Solid router's current path, and send an event if the path is changed.
|
||||
*
|
||||
|
|
@ -274,7 +274,7 @@ export function usePlausiblePageview({ currentPath }: PlausibleMonitorProps): vo
|
|||
}
|
||||
|
||||
/**
|
||||
* Submits a Plausible Analytics `ping` event with a hook.
|
||||
* Submits a Plausible Analytics `'ping'` event with a hook.
|
||||
*
|
||||
* This should watch the Solid router's current path, and send an event if the path is changed.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
//! Handlers for Mod metadata that can be displayed in a GUI mod list or exported as a mod pack
|
||||
|
||||
#[allow(clippy::all)]
|
||||
use async_zip::tokio::read::fs::ZipFileReader;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha2::Digest;
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
use crate::prelude::IOError;
|
||||
use crate::utils::http::{self, write_icon, FetchSemaphore, IoSemaphore};
|
||||
use crate::State;
|
||||
|
||||
|
|
@ -19,65 +14,17 @@ use super::{Cluster, PackagePath};
|
|||
|
||||
/// Creates [`Package`] data for a given [`Cluster`] from on-device files and APIs.
|
||||
/// Paths must be the full paths and not relative paths.
|
||||
#[tracing::instrument(skip(paths, _cluster, _io_semaphore, _fetch_semaphore))]
|
||||
#[tracing::instrument(skip(_paths, _cluster, _io_semaphore, _fetch_semaphore))]
|
||||
#[onelauncher_macros::memory]
|
||||
pub async fn generate_context(
|
||||
_cluster: Cluster,
|
||||
paths: Vec<PathBuf>,
|
||||
_paths: Vec<PathBuf>,
|
||||
_cache_path: PathBuf,
|
||||
_io_semaphore: &IoSemaphore,
|
||||
_fetch_semaphore: &FetchSemaphore,
|
||||
// credentials: &Credentials,
|
||||
) -> crate::Result<HashMap<PackagePath, Package>> {
|
||||
let mut handles = vec![];
|
||||
|
||||
for path in paths {
|
||||
if !path.exists() {
|
||||
continue;
|
||||
}
|
||||
if let Some(ext) = path.extension() {
|
||||
if ext == "txt" {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let handle = tokio::spawn(async move {
|
||||
let mut file = tokio::fs::File::open(path.clone())
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &path))?;
|
||||
|
||||
let mut buffer = [0u8; 65536];
|
||||
let mut hasher = sha2::Sha512::new();
|
||||
|
||||
loop {
|
||||
let read = file.read(&mut buffer).await.map_err(IOError::from)?;
|
||||
if read == 0 {
|
||||
break;
|
||||
}
|
||||
hasher.update(&buffer[..read]);
|
||||
}
|
||||
|
||||
let hash = format!("{:x}", hasher.finalize());
|
||||
Ok::<_, crate::Error>((hash, path))
|
||||
});
|
||||
|
||||
handles.push(handle);
|
||||
}
|
||||
|
||||
let mut file_path_hashes = HashMap::new();
|
||||
|
||||
for handle in handles {
|
||||
let (hash, path) = handle.await??;
|
||||
file_path_hashes.insert(hash, path);
|
||||
}
|
||||
|
||||
let result = HashMap::new();
|
||||
// TODO(pauline): Finish this
|
||||
// let mut stream = tokio_stream::iter(result_packages);
|
||||
// while let Some((k, v)) = stream.next().await {
|
||||
// let k = PackagePath::from_path(k).await?;
|
||||
// result.insert(k, v);
|
||||
// }
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue