fix scrub logic
This commit is contained in:
+7
-1
@@ -21,10 +21,16 @@ pub fn zpool_scrub(pool_name: &str) -> Result<()> {
|
||||
run_command("zpool", vec!["scrub", pool_name])
|
||||
}
|
||||
|
||||
pub fn zpool_wait_scrub(pool_name: &str) -> Result<()> {
|
||||
pub fn zpool_wait_scrub_complete(pool_name: &str) -> Result<()> {
|
||||
run_command("zpool", vec!["wait", "-t", "scrub", pool_name])
|
||||
}
|
||||
|
||||
pub(crate) fn zpool_scrub_in_progress(pool_name: &str) -> Result<bool> {
|
||||
let output = get_output("zpool", vec!["status", pool_name])?;
|
||||
let string = String::from_utf8(output.stdout)?;
|
||||
Ok(string.contains("scrub in progress"))
|
||||
}
|
||||
|
||||
pub fn zpool_status(pool_name: &str) -> Result<String> {
|
||||
let output = get_output("zpool", vec!["status", pool_name])?;
|
||||
let status = String::from_utf8(output.stdout)?;
|
||||
|
||||
+9
-1
@@ -95,7 +95,15 @@ impl ZPool {
|
||||
}
|
||||
|
||||
pub fn scrub(&self) -> Result<()> {
|
||||
zpool_scrub(&self.name)
|
||||
let name = &self.name;
|
||||
|
||||
if !zpool_scrub_in_progress(&self.name)? {
|
||||
println!("scrubbing {name}");
|
||||
zpool_scrub(&self.name)?;
|
||||
}
|
||||
|
||||
println!("waiting for scrub to complete");
|
||||
zpool_wait_scrub_complete(&self.name)
|
||||
}
|
||||
|
||||
pub fn import(name: &str) -> Result<ZPool> {
|
||||
|
||||
Reference in New Issue
Block a user