diff --git a/crates/gitbutler-core/src/projects/project.rs b/crates/gitbutler-core/src/projects/project.rs index a255c7019..e59e70a64 100644 --- a/crates/gitbutler-core/src/projects/project.rs +++ b/crates/gitbutler-core/src/projects/project.rs @@ -87,12 +87,7 @@ pub struct Project { #[serde(default)] pub enable_snapshots: Option, // The number of changed lines that will trigger a snapshot - #[serde(default = "default_snapshot_lines_threshold")] - pub snapshot_lines_threshold: usize, -} - -fn default_snapshot_lines_threshold() -> usize { - 20 + pub snapshot_lines_threshold: Option, } impl Project { @@ -118,4 +113,8 @@ impl Project { pub fn virtual_branches(&self) -> VirtualBranchesHandle { VirtualBranchesHandle::new(self.gb_dir()) } + + pub fn snapshot_lines_threshold(&self) -> usize { + self.snapshot_lines_threshold.unwrap_or(20) + } } diff --git a/crates/gitbutler-watcher/src/handler/mod.rs b/crates/gitbutler-watcher/src/handler/mod.rs index 7777a6757..18c2a6853 100644 --- a/crates/gitbutler-watcher/src/handler/mod.rs +++ b/crates/gitbutler-watcher/src/handler/mod.rs @@ -301,7 +301,7 @@ impl Handler { .get(&project_id) .context("failed to get project")?; let changed_lines = project.lines_since_snapshot()?; - if changed_lines > project.snapshot_lines_threshold { + if changed_lines > project.snapshot_lines_threshold() { project.create_snapshot(SnapshotDetails::new(OperationType::FileChanges))?; } Ok(())