45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
use surrealdb::{opt::PatchOp, Error};
|
|
use tracing::{debug, error};
|
|
|
|
use crate::{
|
|
models::{Record, ServerConfiguration},
|
|
types::DB,
|
|
};
|
|
|
|
pub struct BackupServerService {
|
|
db: DB,
|
|
}
|
|
|
|
impl BackupServerService {
|
|
pub fn new(db: DB) -> Self {
|
|
Self { db }
|
|
}
|
|
pub async fn mark_data_as_processed(&self, conf: &ServerConfiguration) {
|
|
debug!("Updating status on item id:{:?}", conf.id);
|
|
//let updated: Option<Record> = self
|
|
let result: Result<Option<Record>, Error> = self
|
|
.db
|
|
.update(&conf.id)
|
|
.patch(PatchOp::replace("/state/now", "processed"))
|
|
.await;
|
|
|
|
match result {
|
|
Ok(_record) => {
|
|
debug!("Status for item id:`{:?}` has been updated", &conf.id);
|
|
}
|
|
Err(err) => {
|
|
error!(
|
|
"Could not update status for item {:?}. Err:{:?}",
|
|
&conf.id, err
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
pub async fn spawn_restic_container(&self, path: String) {
|
|
debug!("[fake] Spawning container for path {:?}", path);
|
|
}
|
|
pub async fn add_proxy_configuration(&self, path: String) {
|
|
debug!("[fake] Creating caddy configuration {:?}", path);
|
|
}
|
|
}
|