Skip to content

Commit

Permalink
Generalize unset_origin to set_origin
Browse files Browse the repository at this point in the history
Semantics preserving, so pass None where it is invoked.

Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Sep 9, 2024
1 parent 14f4c52 commit 5d945ed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/engine/sim_engine/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ impl SimFilesystem {
}
}

pub fn unset_origin(&mut self) -> bool {
let changed = self.origin.is_some();
self.origin = None;
pub fn set_origin(&mut self, value: Option<FilesystemUuid>) -> bool {
let changed = self.origin != value;
self.origin = value;
changed
}

Expand Down
2 changes: 1 addition & 1 deletion src/engine/sim_engine/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl Pool for SimPool {
// removal.
if let Some((_, sn)) = self.filesystems.get_mut_by_uuid(sn_uuid) {
assert!(
sn.unset_origin(),
sn.set_origin(None),
"A snapshot can only have one origin, so it can be in snapshots.values() only once, so its origin value can be unset only once"
);
updated_origins.push(sn_uuid);
Expand Down
6 changes: 3 additions & 3 deletions src/engine/strat_engine/thinpool/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ impl StratFilesystem {
self.thin_dev.size()
}

pub fn unset_origin(&mut self) -> bool {
let changed = self.origin.is_some();
self.origin = None;
pub fn set_origin(&mut self, value: Option<FilesystemUuid>) -> bool {
let changed = self.origin != value;
self.origin = value;
changed
}

Expand Down
2 changes: 1 addition & 1 deletion src/engine/strat_engine/thinpool/thinpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ impl<B> ThinPool<B> {
// removal.
if let Some((_, sn)) = self.get_mut_filesystem_by_uuid(sn_uuid) {
assert!(
sn.unset_origin(),
sn.set_origin(None),
"A snapshot can only have one origin, so it can be in snapshots.values() only once, so its origin value can be unset only once"
);
updated_origins.push(sn_uuid);
Expand Down

0 comments on commit 5d945ed

Please sign in to comment.