Skip to content

Commit 4194bb0

Browse files
committed
add locking to backend Trait
1 parent 90790f0 commit 4194bb0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/core/src/backend.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::{io::Read, ops::Deref, path::PathBuf, sync::Arc};
1313

1414
use anyhow::Result;
1515
use bytes::Bytes;
16+
use chrono::{DateTime, Local};
1617
use log::trace;
1718
use serde_derive::{Deserialize, Serialize};
1819

@@ -304,6 +305,26 @@ pub trait WriteBackend: ReadBackend {
304305
/// * `id` - The id of the file.
305306
/// * `cacheable` - Whether the file is cacheable.
306307
fn remove(&self, tpe: FileType, id: &Id, cacheable: bool) -> Result<()>;
308+
309+
/// Specify if the backend is able to lock files
310+
fn can_lock(&self) -> bool {
311+
false
312+
}
313+
314+
/// Lock the given file.
315+
///
316+
/// # Arguments
317+
///
318+
/// * `tpe` - The type of the file.
319+
/// * `id` - The id of the file.
320+
/// * `until` - The date until when to lock. May be `None` which usually specifies a unlimited lock
321+
///
322+
/// # Errors
323+
///
324+
/// If the file could not be read.
325+
fn lock(&self, _tpe: FileType, _id: &Id, _until: Option<DateTime<Local>>) -> Result<()> {
326+
Ok(())
327+
}
307328
}
308329

309330
impl WriteBackend for Arc<dyn WriteBackend> {

0 commit comments

Comments
 (0)