treewide: general cleanup

Finally had the time to clean up after myself. Does a bunch of things,
without breakage as far as I'm aware. I've removed around 20 unnecessary
clones, and simplified the architechture a little bit. 

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I4d22337b997a3bf5b0593e6068cd1bd86a6a6964
This commit is contained in:
raf 2026-02-27 21:27:57 +03:00
commit a1357b2501
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
6 changed files with 87 additions and 86 deletions

View file

@ -24,12 +24,6 @@ pub struct Fetcher {
shelve: bool,
}
pub struct FileFetcher {
client: Client,
base_path: PathBuf,
shelve: bool,
}
impl Fetcher {
pub fn new<P: AsRef<Path>>(base_path: P) -> Self {
Self {
@ -44,25 +38,10 @@ impl Fetcher {
self
}
pub async fn fetch_all(
&self,
lockfile: &LockFile,
config: &Config,
) -> Result<()> {
let fetcher = FileFetcher {
client: self.client.clone(),
base_path: self.base_path.clone(),
shelve: self.shelve,
};
fetcher.fetch_all(lockfile, config).await
}
pub async fn sync(&self, lockfile: &LockFile, config: &Config) -> Result<()> {
self.fetch_all(lockfile, config).await
}
}
impl FileFetcher {
/// Fetch all project files according to lockfile with parallel downloads
pub async fn fetch_all(
&self,
@ -94,14 +73,14 @@ impl FileFetcher {
let semaphore = Arc::new(Semaphore::new(MAX_CONCURRENT_DOWNLOADS));
// Prepare download tasks
let client = &self.client;
let base_path = &self.base_path;
let download_tasks: Vec<_> = exportable_projects
.iter()
.map(|project| {
let semaphore = Arc::clone(&semaphore);
let client = self.client.clone();
let base_path = self.base_path.clone();
let lockfile = lockfile.clone();
let config = config.clone();
let client = client.clone();
let base_path = base_path.clone();
let project = (*project).clone();
let overall_bar = overall_bar.clone();
@ -111,11 +90,7 @@ impl FileFetcher {
PakkerError::InternalError("Semaphore acquisition failed".into())
})?;
let name = project
.name
.values()
.next()
.map_or("unknown".to_string(), std::clone::Clone::clone);
let name = project.get_name();
let fetcher = Self {
client,
@ -123,8 +98,7 @@ impl FileFetcher {
shelve: false, // Shelving happens at sync level, not per-project
};
let result =
fetcher.fetch_project(&project, &lockfile, &config).await;
let result = fetcher.fetch_project(&project, lockfile, config).await;
// Update progress bar
overall_bar.inc(1);