feat(compression): implement transparent LZ4 chunk compression with V1 backwards compatibility
This commit is contained in:
+13
-2
@@ -5,7 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use rusqlite::{params, Connection, OptionalExtension};
|
||||
|
||||
use crate::crypto::{KdfParams, FORMAT_VERSION, MAGIC_BYTES};
|
||||
use crate::crypto::{KdfParams, FORMAT_VERSION, FORMAT_VERSION_V1, FORMAT_VERSION_V2, MAGIC_BYTES};
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -190,10 +190,11 @@ impl Database {
|
||||
bail!("Ungültige Sanctum-Containerdatei: Magic Bytes stimmen nicht überein");
|
||||
}
|
||||
|
||||
if meta.1 != FORMAT_VERSION {
|
||||
if meta.1 != FORMAT_VERSION_V1 && meta.1 != FORMAT_VERSION_V2 {
|
||||
bail!("Nicht unterstützte Sanctum-Formatversion: {}", meta.1);
|
||||
}
|
||||
|
||||
|
||||
if meta.2.len() != 16 {
|
||||
bail!("Ungültige Salt-Länge im Header");
|
||||
}
|
||||
@@ -254,6 +255,16 @@ impl Database {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Aktualisiert die Version in der meta-Tabelle (z. B. für Migrationen oder Tests).
|
||||
pub fn set_meta_version(&self, version: u32) -> Result<()> {
|
||||
let conn = self.conn.lock().unwrap();
|
||||
let rows_affected = conn.execute("UPDATE meta SET version = ?1", params![version])?;
|
||||
if rows_affected == 0 {
|
||||
bail!("Konnte Container-Version nicht aktualisieren: meta-Tabelle ist leer");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Löst einen hierarchischen Pfad (z. B. "/ordner/datei.txt") in den entsprechenden NodeRecord auf.
|
||||
pub fn resolve_path(&self, raw_path: &str) -> Result<Option<NodeRecord>> {
|
||||
let normalized = raw_path.trim_matches('/');
|
||||
|
||||
Reference in New Issue
Block a user