Small database sync update
This commit is contained in:
1 parent
8b673e52da
commit
824a868d73
4 files changed
+14
-7
No files matched your search
@@ -76,12 +76,9 @@ pub fn default_connection() -> Connection {
|
||||
.expect("Failed to set PRAGMA");
|
||||
connection
|
||||
.query_one("PRAGMA journal_mode = WAL;", [], |row| {
|
||||
println!("{:?}", row);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap_or_else(|e| {
|
||||
println!("{}", e);
|
||||
});
|
||||
.expect("Failed to init database");
|
||||
connection
|
||||
.execute("PRAGMA synchronous = NORMAL;", [])
|
||||
.expect("Failed to set PRAGMA");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::fs::*;
|
||||
use crate::notification::NotificationData::{CompressError, PermissionDenied, WebApiUnavailable};
|
||||
use crate::notification::NotificationData::{CompressError, OpenFileError, PermissionDenied, WebApiUnavailable};
|
||||
use crate::notification::{MaybeError, NotificationData};
|
||||
use log::info;
|
||||
use std::io;
|
||||
use tokio::fs::{File, OpenOptions};
|
||||
use tokio::fs::{remove_file, File, OpenOptions};
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use zstd::{DEFAULT_COMPRESSION_LEVEL, Decoder, Encoder};
|
||||
|
||||
@@ -74,6 +74,8 @@ pub async fn load_data(id: String, temp: bool) -> MaybeError {
|
||||
.await
|
||||
.map_err(|_| WebApiUnavailable)?;
|
||||
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(())
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,14 @@ pub fn app_data_dir() -> PathBuf {
|
||||
pub fn db_path() -> PathBuf {
|
||||
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 {
|
||||
app_data_dir().join("data.db.tmp")
|
||||
}
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ impl NavigatedPage<SyncMessage> for SyncState {
|
||||
return tasks;
|
||||
}
|
||||
GetLast => {
|
||||
if self.real_load == false {
|
||||
if !self.real_load {
|
||||
self.real_load = true;
|
||||
return Task::batch([
|
||||
Task::future(async {
|
||||
|
||||
Reference in new issue
Block a user