This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
113: snapshots r=MarinPostma a=MarinPostma This pr adds support for snapshoting. The snapshoting process for an index requires that no other update is processing at the same time. A mutex lock has been added to prevent a snapshot from occuring at the same time as an update, while still premitting updates to be pushed. The list of the indexes to snapshot is first retrieved from the `UuidResolver` which also performs its snapshot. This list is passed to the update store, which attempts to acquire a lock on the update store while it snaphots itself and it's associated index store. This means that a snapshot can only be completed once all indexes have finished their ongoing update. This pr also adds refactoring of the code to allow unit testing and mocking, and unit test the snapshot creation. Co-authored-by: mpostma <postma.marin@protonmail.com> Co-authored-by: tamo <irevoire@protonmail.ch> Co-authored-by: marin <postma.marin@protonmail.com> Co-authored-by: Marin Postma <postma.marin@protonmail.com>
- Loading branch information
Showing
34 changed files
with
2,249 additions
and
1,587 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
use flate2::read::GzDecoder; | ||
use flate2::write::GzEncoder; | ||
use flate2::Compression; | ||
use std::fs::{create_dir_all, File}; | ||
use std::io::Write; | ||
use std::path::Path; | ||
use tar::{Archive, Builder}; | ||
|
||
use crate::error::Error; | ||
use flate2::{read::GzDecoder, write::GzEncoder, Compression}; | ||
use tar::{Archive, Builder}; | ||
|
||
pub fn to_tar_gz(src: &Path, dest: &Path) -> Result<(), Error> { | ||
let f = File::create(dest)?; | ||
let gz_encoder = GzEncoder::new(f, Compression::default()); | ||
pub fn to_tar_gz(src: impl AsRef<Path>, dest: impl AsRef<Path>) -> anyhow::Result<()> { | ||
let mut f = File::create(dest)?; | ||
let gz_encoder = GzEncoder::new(&mut f, Compression::default()); | ||
let mut tar_encoder = Builder::new(gz_encoder); | ||
tar_encoder.append_dir_all(".", src)?; | ||
let gz_encoder = tar_encoder.into_inner()?; | ||
gz_encoder.finish()?; | ||
f.flush()?; | ||
Ok(()) | ||
} | ||
|
||
pub fn from_tar_gz(src: &Path, dest: &Path) -> Result<(), Error> { | ||
let f = File::open(src)?; | ||
pub fn from_tar_gz(src: impl AsRef<Path>, dest: impl AsRef<Path>) -> anyhow::Result<()> { | ||
let f = File::open(&src)?; | ||
let gz = GzDecoder::new(f); | ||
let mut ar = Archive::new(gz); | ||
create_dir_all(dest)?; | ||
ar.unpack(dest)?; | ||
create_dir_all(&dest)?; | ||
ar.unpack(&dest)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.