alpm.rs
alpm.rs copied to clipboard
Noob issue : "failed to retrieve some files"
So i keep hitting this error and I wonder if I'm doing something wrong.
fn main() {
let root = "/home/user";
let dbpath = "/home/user/.local/lib/pacman";
let mut alpm = match alpm::Alpm::new(root, dbpath) {
Ok(alpm) => alpm,
Err(err) => {
eprintln!("Failed to initialize ALPM: {}", err);
return;
}
};
let core = alpm
.register_syncdb_mut("kde-unstable", SigLevel::USE_DEFAULT)
.unwrap();
core.add_server("http://mirror.4v1.in/archlinux/core/os/x86_x64").unwrap();
// Added more servers here
core.set_usage(Usage::SYNC | Usage::SEARCH).unwrap();
match alpm.syncdbs_mut().update(true) {
Ok(updated) => {
if updated {
println!("Database was updated." )
} else {
println!("Database is up to date.");
}
}
Err(e) => {
eprintln!("Failed to update database. {}", e);
}
}
}
If you add a logging callback you can see the mirror times out
registering sync database 'kde-unstable'
database path for tree kde-unstable set to /home/morganamilo/aa/sync/kde-unstable.db
"/home/morganamilo/aa/sync/kde-unstable.db" is not readable: No such file or directory
adding new server URL to database 'kde-unstable': http://mirror.4v1.in/archlinux/core/os/x86_x64
kde-unstable.db: url is http://mirror.4v1.in/archlinux/core/os/x86_x64/kde-unstable.db
kde-unstable.db: maxsize 134217728
kde-unstable.db: opened tempfile for download: /home/morganamilo/aa/sync/download-lVEAli/kde-unstable.db.part (wb)
kde-unstable.db: curl returned result 28 from transfer
failed retrieving file 'kde-unstable.db' from mirror.4v1.in : Connection timed out after 10001 milliseconds
kde-unstable.db: no more servers to retry
curl_download_internal return code is -1
failed to sync dbs: download library error
Failed to update database. download library error
unregistering database 'local'
unregistering database 'kde-unstable'
This mirror is working with pacman just fine. I have also tested with more worldwide mirrors and local mirrors which are working just fine with pacman too. Might I add, I have also tested with core and extra repos as well.
I think there must be some other underlying issue. Could you please provide me with the code for the callback you are using.
use alpm::*;
fn main() {
let root = "/home/user";
let mut alpm = match alpm::Alpm::new(root, dbpath) {
Ok(alpm) => alpm,
Err(err) => {
eprintln!("Failed to initialize ALPM: {}", err);
return;
}
};
alpm.set_log_cb((), logcb);
let core = alpm
.register_syncdb_mut("kde-unstable", SigLevel::USE_DEFAULT)
.unwrap();
core.add_server("http://mirror.4v1.in/archlinux/core/os/x86_x64")
.unwrap();
// Added more servers here
core.set_usage(Usage::SYNC | Usage::SEARCH).unwrap();
match alpm.syncdbs_mut().update(true) {
Ok(updated) => {
if updated {
println!("Database was updated.")
} else {
println!("Database is up to date.");
}
}
Err(e) => {
eprintln!("Failed to update database. {}", e);
}
}
}
fn logcb(_level: LogLevel, msg: &str, _: &mut ()) {
print!("{msg}");
}