initial commit
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ife1391ed23a1e7f388b1b5eca90b9ea76a6a6964
This commit is contained in:
commit
ef28bdaeb4
63 changed files with 17292 additions and 0 deletions
49
src/cli/commands/fetch.rs
Normal file
49
src/cli/commands/fetch.rs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::{
|
||||
cli::FetchArgs,
|
||||
error::Result,
|
||||
fetch::Fetcher,
|
||||
ipc::{IpcCoordinator, OperationGuard, OperationType},
|
||||
model::{Config, LockFile},
|
||||
};
|
||||
|
||||
pub async fn execute(
|
||||
args: FetchArgs,
|
||||
lockfile_path: &Path,
|
||||
config_path: &Path,
|
||||
) -> Result<()> {
|
||||
// Load expects directory path, so get parent directory
|
||||
let lockfile_dir = lockfile_path.parent().unwrap_or(Path::new("."));
|
||||
let config_dir = config_path.parent().unwrap_or(Path::new("."));
|
||||
|
||||
let lockfile = LockFile::load(lockfile_dir)?;
|
||||
let config = Config::load(config_dir)?;
|
||||
|
||||
// Create IPC coordinator for this modpack
|
||||
let working_dir = PathBuf::from(".");
|
||||
let coordinator = IpcCoordinator::new(&working_dir)?;
|
||||
|
||||
// Check for conflicting operations
|
||||
if coordinator.has_running_operation(OperationType::Fetch) {
|
||||
// Wait for conflicting operations to complete with timeout
|
||||
let timeout = std::time::Duration::from_secs(args.timeout.unwrap_or(300));
|
||||
coordinator
|
||||
.wait_for_conflicts(OperationType::Fetch, timeout)
|
||||
.await?;
|
||||
}
|
||||
|
||||
// Register this fetch operation
|
||||
let operation_id = coordinator.register_operation(OperationType::Fetch)?;
|
||||
let _guard = OperationGuard::new(coordinator, operation_id);
|
||||
|
||||
// Create fetcher
|
||||
let fetcher = Fetcher::new(".");
|
||||
|
||||
// Fetch all projects (progress indicators handled in fetch.rs)
|
||||
fetcher.fetch_all(&lockfile, &config).await?;
|
||||
|
||||
println!("Fetch complete");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue