Enablement of experimental lazy database initialization

This commit is contained in:
Xavier Moffett 2024-04-26 17:15:32 -04:00
parent d8a81436a1
commit aeadbd4aa4
Signed by: Sapphirus
GPG key ID: A6C061B2CEA1A7AC
5 changed files with 27 additions and 9 deletions

View file

@ -99,13 +99,14 @@ pub trait Transaction {
bitflags! {
pub struct TransactionFlags: u8 {
const NONE = 0;
const TARGET_ONLY = 0b0000001;
const PREVIEW = 0b0000010;
const NO_CONFIRM = 0b0000100;
const FORCE_DATABASE = 0b0001000;
const DATABASE_ONLY = 0b0010000;
const CREATE = 0b0100000;
const FILESYSTEM_SYNC = 0b1000000;
const TARGET_ONLY = 0b00000001;
const PREVIEW = 0b00000010;
const NO_CONFIRM = 0b00000100;
const FORCE_DATABASE = 0b00001000;
const DATABASE_ONLY = 0b00010000;
const CREATE = 0b00100000;
const FILESYSTEM_SYNC = 0b01000000;
const LAZY_LOAD_DB = 0b10000000;
}
}

View file

@ -75,10 +75,11 @@ impl Transaction for Prepare {
}
let create = ag.flags().contains(TransactionFlags::CREATE);
let lazy_load = ag.flags().contains(TransactionFlags::LAZY_LOAD_DB);
let timestamp = inshandle.metadata().timestamp();
let present = *UNIX_TIMESTAMP;
if create && present == timestamp {
if !lazy_load && create && present == timestamp {
handle.enumerate_foreign_queue();
}
}

View file

@ -32,6 +32,7 @@ use pacwrap_core::{
utils::{
arguments::{Arguments, InvalidArgument::*, Operand as Op},
check_root,
print_warning,
prompt::prompt_targets,
},
Error,
@ -176,6 +177,7 @@ fn engage_aggregator<'a>(args: &mut Arguments, lock: &'a Lock) -> Result<()> {
compose.insert(instance, None);
}
},
Op::Short('l') | Op::Long("lazy-load") => flags = flags | TransactionFlags::LAZY_LOAD_DB,
Op::Short('f') | Op::Long("force") => force = true,
Op::Short('r') | Op::Long("reinitialize") => reinitialize = true,
Op::Short('t') | Op::Long("target") => match args.next() {
@ -226,6 +228,12 @@ fn engage_aggregator<'a>(args: &mut Arguments, lock: &'a Lock) -> Result<()> {
delete_containers(&cache, lock, &mut logger, &delete, &flags, force)?;
}
if flags.contains(TransactionFlags::LAZY_LOAD_DB) {
print_warning("Database lazy-loading triggered by `-l/--lazy-load`; this feature is experimental.");
print_warning("In future, manual intervention may be required for missing dependencies.");
print_warning("See `--help compose` or the pacwrap(1) man page for further information.");
}
cache = instantiate(compose_handles(&cache, compose)?, cache, lock, &mut logger)?;
acquire_targets(&cache, &mut targets, &mut queue)?;
Ok(TransactionAggregator::new(&cache, &mut logger, TransactionType::Upgrade(true, true, false))

View file

@ -35,6 +35,7 @@ use pacwrap_core::{
utils::{
arguments::{Arguments, InvalidArgument::*, Operand as Op},
check_root,
print_warning,
},
ErrorKind,
};
@ -169,6 +170,7 @@ fn engage_aggregator<'a>(
Op::Long("dbonly") => flags = flags | TransactionFlags::DATABASE_ONLY,
Op::Long("force-foreign") => flags = flags | TransactionFlags::FORCE_DATABASE,
Op::Long("noconfirm") => flags = flags | TransactionFlags::NO_CONFIRM,
Op::Short('l') | Op::Long("lazy-load") => flags = flags | TransactionFlags::LAZY_LOAD_DB,
Op::Short('o') | Op::Long("target-only") => flags = flags | TransactionFlags::TARGET_ONLY,
Op::Short('f') | Op::Long("filesystem") => flags = flags | TransactionFlags::FILESYSTEM_SYNC,
Op::Short('p') | Op::Long("preview") => flags = flags | TransactionFlags::PREVIEW,
@ -238,6 +240,12 @@ fn engage_aggregator<'a>(
}
}
if flags.contains(TransactionFlags::LAZY_LOAD_DB) {
print_warning("Database lazy-loading triggered by `-l/--lazy-load`; this feature is experimental.");
print_warning("In future, manual intervention may be required for missing dependencies.");
print_warning("See `--help sync` or the pacwrap(1) man page for further information.");
}
if create_targets.len() > 0 || init {
if flags.intersects(TransactionFlags::PREVIEW) {
err!(ErrorKind::Message("Container creation cannot be previewed."))?;

View file

@ -78,7 +78,7 @@ pub fn remove_containers(args: &mut Arguments) -> Result<()> {
}
}
let cache = cache::populate_config()?;
let cache = cache::populate()?;
let instances = cache.filter_target(&targets, vec![]);
if instances.len() != targets.len() {