Enablement of experimental lazy database initialization
This commit is contained in:
parent
d8a81436a1
commit
aeadbd4aa4
5 changed files with 27 additions and 9 deletions
|
@ -99,13 +99,14 @@ pub trait Transaction {
|
||||||
bitflags! {
|
bitflags! {
|
||||||
pub struct TransactionFlags: u8 {
|
pub struct TransactionFlags: u8 {
|
||||||
const NONE = 0;
|
const NONE = 0;
|
||||||
const TARGET_ONLY = 0b0000001;
|
const TARGET_ONLY = 0b00000001;
|
||||||
const PREVIEW = 0b0000010;
|
const PREVIEW = 0b00000010;
|
||||||
const NO_CONFIRM = 0b0000100;
|
const NO_CONFIRM = 0b00000100;
|
||||||
const FORCE_DATABASE = 0b0001000;
|
const FORCE_DATABASE = 0b00001000;
|
||||||
const DATABASE_ONLY = 0b0010000;
|
const DATABASE_ONLY = 0b00010000;
|
||||||
const CREATE = 0b0100000;
|
const CREATE = 0b00100000;
|
||||||
const FILESYSTEM_SYNC = 0b1000000;
|
const FILESYSTEM_SYNC = 0b01000000;
|
||||||
|
const LAZY_LOAD_DB = 0b10000000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,11 @@ impl Transaction for Prepare {
|
||||||
}
|
}
|
||||||
|
|
||||||
let create = ag.flags().contains(TransactionFlags::CREATE);
|
let create = ag.flags().contains(TransactionFlags::CREATE);
|
||||||
|
let lazy_load = ag.flags().contains(TransactionFlags::LAZY_LOAD_DB);
|
||||||
let timestamp = inshandle.metadata().timestamp();
|
let timestamp = inshandle.metadata().timestamp();
|
||||||
let present = *UNIX_TIMESTAMP;
|
let present = *UNIX_TIMESTAMP;
|
||||||
|
|
||||||
if create && present == timestamp {
|
if !lazy_load && create && present == timestamp {
|
||||||
handle.enumerate_foreign_queue();
|
handle.enumerate_foreign_queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ use pacwrap_core::{
|
||||||
utils::{
|
utils::{
|
||||||
arguments::{Arguments, InvalidArgument::*, Operand as Op},
|
arguments::{Arguments, InvalidArgument::*, Operand as Op},
|
||||||
check_root,
|
check_root,
|
||||||
|
print_warning,
|
||||||
prompt::prompt_targets,
|
prompt::prompt_targets,
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
|
@ -176,6 +177,7 @@ fn engage_aggregator<'a>(args: &mut Arguments, lock: &'a Lock) -> Result<()> {
|
||||||
compose.insert(instance, None);
|
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('f') | Op::Long("force") => force = true,
|
||||||
Op::Short('r') | Op::Long("reinitialize") => reinitialize = true,
|
Op::Short('r') | Op::Long("reinitialize") => reinitialize = true,
|
||||||
Op::Short('t') | Op::Long("target") => match args.next() {
|
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)?;
|
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)?;
|
cache = instantiate(compose_handles(&cache, compose)?, cache, lock, &mut logger)?;
|
||||||
acquire_targets(&cache, &mut targets, &mut queue)?;
|
acquire_targets(&cache, &mut targets, &mut queue)?;
|
||||||
Ok(TransactionAggregator::new(&cache, &mut logger, TransactionType::Upgrade(true, true, false))
|
Ok(TransactionAggregator::new(&cache, &mut logger, TransactionType::Upgrade(true, true, false))
|
||||||
|
|
|
@ -35,6 +35,7 @@ use pacwrap_core::{
|
||||||
utils::{
|
utils::{
|
||||||
arguments::{Arguments, InvalidArgument::*, Operand as Op},
|
arguments::{Arguments, InvalidArgument::*, Operand as Op},
|
||||||
check_root,
|
check_root,
|
||||||
|
print_warning,
|
||||||
},
|
},
|
||||||
ErrorKind,
|
ErrorKind,
|
||||||
};
|
};
|
||||||
|
@ -169,6 +170,7 @@ fn engage_aggregator<'a>(
|
||||||
Op::Long("dbonly") => flags = flags | TransactionFlags::DATABASE_ONLY,
|
Op::Long("dbonly") => flags = flags | TransactionFlags::DATABASE_ONLY,
|
||||||
Op::Long("force-foreign") => flags = flags | TransactionFlags::FORCE_DATABASE,
|
Op::Long("force-foreign") => flags = flags | TransactionFlags::FORCE_DATABASE,
|
||||||
Op::Long("noconfirm") => flags = flags | TransactionFlags::NO_CONFIRM,
|
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('o') | Op::Long("target-only") => flags = flags | TransactionFlags::TARGET_ONLY,
|
||||||
Op::Short('f') | Op::Long("filesystem") => flags = flags | TransactionFlags::FILESYSTEM_SYNC,
|
Op::Short('f') | Op::Long("filesystem") => flags = flags | TransactionFlags::FILESYSTEM_SYNC,
|
||||||
Op::Short('p') | Op::Long("preview") => flags = flags | TransactionFlags::PREVIEW,
|
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 create_targets.len() > 0 || init {
|
||||||
if flags.intersects(TransactionFlags::PREVIEW) {
|
if flags.intersects(TransactionFlags::PREVIEW) {
|
||||||
err!(ErrorKind::Message("Container creation cannot be previewed."))?;
|
err!(ErrorKind::Message("Container creation cannot be previewed."))?;
|
||||||
|
|
|
@ -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![]);
|
let instances = cache.filter_target(&targets, vec![]);
|
||||||
|
|
||||||
if instances.len() != targets.len() {
|
if instances.len() != targets.len() {
|
||||||
|
|
Loading…
Reference in a new issue