mirror of
https://github.com/edu4rdshl/rusnapshot.git
synced 2026-07-17 23:24:55 +00:00
Avoid sqlite database aggressive locking.
- https://sqlite.org/wal.html
This commit is contained in:
parent
8f3c794631
commit
31cf4d1a90
2 changed files with 6 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ use {
|
||||||
|
|
||||||
pub fn manage_creation(args: &mut Args) -> Result<()> {
|
pub fn manage_creation(args: &mut Args) -> Result<()> {
|
||||||
let connection = sqlite::open(&args.database_file)?;
|
let connection = sqlite::open(&args.database_file)?;
|
||||||
|
connection.execute("PRAGMA journal_mode=WAL")?;
|
||||||
args.snapshot_name = format!(
|
args.snapshot_name = format!(
|
||||||
"{}-{}",
|
"{}-{}",
|
||||||
args.snapshot_prefix,
|
args.snapshot_prefix,
|
||||||
|
|
@ -23,6 +24,7 @@ pub fn manage_creation(args: &mut Args) -> Result<()> {
|
||||||
|
|
||||||
pub fn manage_deletion(args: &mut Args) -> Result<()> {
|
pub fn manage_deletion(args: &mut Args) -> Result<()> {
|
||||||
let connection = sqlite::open(&args.database_file)?;
|
let connection = sqlite::open(&args.database_file)?;
|
||||||
|
connection.execute("PRAGMA journal_mode=WAL")?;
|
||||||
let snapshot_data = database::return_snapshot_data(&connection, args)?;
|
let snapshot_data = database::return_snapshot_data(&connection, args)?;
|
||||||
if !snapshot_data.snap_id.is_empty() {
|
if !snapshot_data.snap_id.is_empty() {
|
||||||
args.snapshot_name = snapshot_data.destination + &snapshot_data.name;
|
args.snapshot_name = snapshot_data.destination + &snapshot_data.name;
|
||||||
|
|
@ -42,6 +44,7 @@ pub fn manage_deletion(args: &mut Args) -> Result<()> {
|
||||||
|
|
||||||
pub fn manage_restoring(args: &mut Args) -> Result<()> {
|
pub fn manage_restoring(args: &mut Args) -> Result<()> {
|
||||||
let connection = sqlite::open(&args.database_file)?;
|
let connection = sqlite::open(&args.database_file)?;
|
||||||
|
connection.execute("PRAGMA journal_mode=WAL")?;
|
||||||
let snapshot_data = database::return_snapshot_data(&connection, args)?;
|
let snapshot_data = database::return_snapshot_data(&connection, args)?;
|
||||||
if !snapshot_data.snap_id.is_empty() {
|
if !snapshot_data.snap_id.is_empty() {
|
||||||
args.snapshot_name = snapshot_data.destination + &snapshot_data.name;
|
args.snapshot_name = snapshot_data.destination + &snapshot_data.name;
|
||||||
|
|
@ -67,6 +70,7 @@ pub fn manage_restoring(args: &mut Args) -> Result<()> {
|
||||||
|
|
||||||
pub fn manage_listing(args: &mut Args) -> Result<()> {
|
pub fn manage_listing(args: &mut Args) -> Result<()> {
|
||||||
let connection = sqlite::open(&args.database_file)?;
|
let connection = sqlite::open(&args.database_file)?;
|
||||||
|
connection.execute("PRAGMA journal_mode=WAL")?;
|
||||||
let snaps_data = database::return_all_data(&connection)?;
|
let snaps_data = database::return_all_data(&connection)?;
|
||||||
|
|
||||||
let mut table = Table::new();
|
let mut table = Table::new();
|
||||||
|
|
@ -95,6 +99,7 @@ pub fn manage_listing(args: &mut Args) -> Result<()> {
|
||||||
|
|
||||||
pub fn keep_only_x(args: &mut Args) -> Result<()> {
|
pub fn keep_only_x(args: &mut Args) -> Result<()> {
|
||||||
let connection = sqlite::open(&args.database_file)?;
|
let connection = sqlite::open(&args.database_file)?;
|
||||||
|
connection.execute("PRAGMA journal_mode=WAL")?;
|
||||||
let snaps_data = database::return_only_x_items(&connection, args)?;
|
let snaps_data = database::return_only_x_items(&connection, args)?;
|
||||||
for data in &snaps_data {
|
for data in &snaps_data {
|
||||||
args.snapshot_name = data.destination.clone() + &data.name;
|
args.snapshot_name = data.destination.clone() + &data.name;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use {
|
||||||
|
|
||||||
pub fn test_database(connection_str: &str) -> Result<()> {
|
pub fn test_database(connection_str: &str) -> Result<()> {
|
||||||
let connection = sqlite::open(&connection_str)?;
|
let connection = sqlite::open(&connection_str)?;
|
||||||
|
connection.execute("PRAGMA journal_mode=WAL")?;
|
||||||
drop(connection);
|
drop(connection);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue