Small database sync update

This commit is contained in:
micialware committed 2026-09-22 21:57:29 +03:00
1 parent 8b673e52da
commit 824a868d73
4 files changed
+14 -7

No files matched your search

+1 -4
View File
@@ -76,12 +76,9 @@ pub fn default_connection() -> Connection {
.expect("Failed to set PRAGMA"); .expect("Failed to set PRAGMA");
connection connection
.query_one("PRAGMA journal_mode = WAL;", [], |row| { .query_one("PRAGMA journal_mode = WAL;", [], |row| {
println!("{:?}", row);
Ok(()) Ok(())
}) })
.unwrap_or_else(|e| { .expect("Failed to init database");
println!("{}", e);
});
connection connection
.execute("PRAGMA synchronous = NORMAL;", []) .execute("PRAGMA synchronous = NORMAL;", [])
.expect("Failed to set PRAGMA"); .expect("Failed to set PRAGMA");
+4 -2
View File
@@ -1,9 +1,9 @@
use crate::fs::*; use crate::fs::*;
use crate::notification::NotificationData::{CompressError, PermissionDenied, WebApiUnavailable}; use crate::notification::NotificationData::{CompressError, OpenFileError, PermissionDenied, WebApiUnavailable};
use crate::notification::{MaybeError, NotificationData}; use crate::notification::{MaybeError, NotificationData};
use log::info; use log::info;
use std::io; use std::io;
use tokio::fs::{File, OpenOptions}; use tokio::fs::{remove_file, File, OpenOptions};
use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::io::{AsyncReadExt, AsyncWriteExt};
use zstd::{DEFAULT_COMPRESSION_LEVEL, Decoder, Encoder}; use zstd::{DEFAULT_COMPRESSION_LEVEL, Decoder, Encoder};
@@ -74,6 +74,8 @@ pub async fn load_data(id: String, temp: bool) -> MaybeError {
.await .await
.map_err(|_| WebApiUnavailable)?; .map_err(|_| WebApiUnavailable)?;
set_local_version(version.parse::<u32>().unwrap_or_default()).await?; set_local_version(version.parse::<u32>().unwrap_or_default()).await?;
remove_file(db_wal()).await.map_err(|_| OpenFileError)?;
remove_file(db_wal()).await.map_err(|_| OpenFileError)?;
Ok(()) Ok(())
} }
+8
View File
@@ -16,6 +16,14 @@ pub fn app_data_dir() -> PathBuf {
pub fn db_path() -> PathBuf { pub fn db_path() -> PathBuf {
app_data_dir().join("data.db") app_data_dir().join("data.db")
} }
pub fn db_wal() -> PathBuf {
app_data_dir().join("data.db-wal")
}
pub fn db_shm() -> PathBuf {
app_data_dir().join("data.db-shm")
}
pub fn temp_db_path() -> PathBuf { pub fn temp_db_path() -> PathBuf {
app_data_dir().join("data.db.tmp") app_data_dir().join("data.db.tmp")
} }
+1 -1
View File
@@ -102,7 +102,7 @@ impl NavigatedPage<SyncMessage> for SyncState {
return tasks; return tasks;
} }
GetLast => { GetLast => {
if self.real_load == false { if !self.real_load {
self.real_load = true; self.real_load = true;
return Task::batch([ return Task::batch([
Task::future(async { Task::future(async {