Snapshot takes compression and compaction options

This commit is contained in:
Louis Dureuil
2025-04-07 08:31:39 +02:00
parent c3c5a928e4
commit 7115b29a8c
13 changed files with 267 additions and 66 deletions

View File

@@ -7,9 +7,14 @@ use flate2::write::GzEncoder;
use flate2::Compression;
use tar::{Archive, Builder};
pub fn to_tar_gz(src: impl AsRef<Path>, dest: impl AsRef<Path>) -> anyhow::Result<()> {
pub fn to_tar_gz(
src: impl AsRef<Path>,
dest: impl AsRef<Path>,
compression: bool,
) -> anyhow::Result<()> {
let compression = if compression { Compression::default() } else { Compression::none() };
let mut f = File::create(dest)?;
let gz_encoder = GzEncoder::new(&mut f, Compression::default());
let gz_encoder = GzEncoder::new(&mut f, compression);
let mut tar_encoder = Builder::new(gz_encoder);
tar_encoder.append_dir_all(".", src)?;
let gz_encoder = tar_encoder.into_inner()?;

View File

@@ -328,6 +328,7 @@ InvalidSettingsDictionary , InvalidRequest , BAD_REQUEST ;
InvalidSettingsSynonyms , InvalidRequest , BAD_REQUEST ;
InvalidSettingsTypoTolerance , InvalidRequest , BAD_REQUEST ;
InvalidSettingsLocalizedAttributes , InvalidRequest , BAD_REQUEST ;
InvalidSnapshotOptions , InvalidRequest , BAD_REQUEST ;
InvalidState , Internal , INTERNAL_SERVER_ERROR ;
InvalidStoreFile , Internal , INTERNAL_SERVER_ERROR ;
InvalidSwapDuplicateIndexFound , InvalidRequest , BAD_REQUEST ;

View File

@@ -48,6 +48,7 @@ impl Task {
match &self.kind {
DumpCreation { .. }
| SnapshotCreation
| SnapshotCreationWithParams { .. }
| TaskCancelation { .. }
| TaskDeletion { .. }
| UpgradeDatabase { .. }
@@ -86,6 +87,7 @@ impl Task {
| KindWithContent::TaskDeletion { .. }
| KindWithContent::DumpCreation { .. }
| KindWithContent::SnapshotCreation
| KindWithContent::SnapshotCreationWithParams { .. }
| KindWithContent::UpgradeDatabase { .. } => None,
}
}
@@ -152,6 +154,10 @@ pub enum KindWithContent {
instance_uid: Option<InstanceUid>,
},
SnapshotCreation,
SnapshotCreationWithParams {
compaction: bool,
compression: bool,
},
UpgradeDatabase {
from: (u32, u32, u32),
},
@@ -180,6 +186,7 @@ impl KindWithContent {
KindWithContent::TaskDeletion { .. } => Kind::TaskDeletion,
KindWithContent::DumpCreation { .. } => Kind::DumpCreation,
KindWithContent::SnapshotCreation => Kind::SnapshotCreation,
KindWithContent::SnapshotCreationWithParams { .. } => Kind::SnapshotCreation,
KindWithContent::UpgradeDatabase { .. } => Kind::UpgradeDatabase,
}
}
@@ -190,6 +197,7 @@ impl KindWithContent {
match self {
DumpCreation { .. }
| SnapshotCreation
| SnapshotCreationWithParams { .. }
| TaskCancelation { .. }
| TaskDeletion { .. }
| UpgradeDatabase { .. } => vec![],
@@ -269,6 +277,7 @@ impl KindWithContent {
}),
KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }),
KindWithContent::SnapshotCreation => None,
KindWithContent::SnapshotCreationWithParams { .. } => None,
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: (from.0, from.1, from.2),
to: (
@@ -335,6 +344,7 @@ impl KindWithContent {
}),
KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }),
KindWithContent::SnapshotCreation => None,
KindWithContent::SnapshotCreationWithParams { .. } => None,
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: *from,
to: (
@@ -383,6 +393,7 @@ impl From<&KindWithContent> for Option<Details> {
}),
KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }),
KindWithContent::SnapshotCreation => None,
KindWithContent::SnapshotCreationWithParams { .. } => None,
KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase {
from: *from,
to: (