datastore: use new ProcessLocker
To make sure only one process runs garbage collection while having active writers.
This commit is contained in:
@ -340,6 +340,8 @@ impl std::io::Seek for BufferedDynamicReader {
|
||||
|
||||
pub struct DynamicIndexWriter {
|
||||
store: Arc<ChunkStore>,
|
||||
_lock: tools::ProcessLockSharedGuard,
|
||||
|
||||
chunker: Chunker,
|
||||
writer: BufWriter<File>,
|
||||
closed: bool,
|
||||
@ -366,6 +368,8 @@ impl DynamicIndexWriter {
|
||||
|
||||
pub fn create(store: Arc<ChunkStore>, path: &Path, chunk_size: usize) -> Result<Self, Error> {
|
||||
|
||||
let shared_lock = store.try_shared_lock()?;
|
||||
|
||||
let full_path = store.relative_path(path);
|
||||
let mut tmp_path = full_path.clone();
|
||||
tmp_path.set_extension("tmp_didx");
|
||||
@ -400,6 +404,7 @@ impl DynamicIndexWriter {
|
||||
|
||||
Ok(Self {
|
||||
store,
|
||||
_lock: shared_lock,
|
||||
chunker: Chunker::new(chunk_size),
|
||||
writer: writer,
|
||||
closed: false,
|
||||
|
Reference in New Issue
Block a user