File size: 450 Bytes
854994d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Removes stale snapshots before planned daemon replacements.

use std::io::ErrorKind;

use anyhow::Context;
use anyhow::Result;

use crate::Daemon;

pub(crate) fn discard_pending(daemon: &Daemon) -> Result<()> {
    match std::fs::remove_file(daemon.recovery_file()?) {
        Ok(()) => Ok(()),
        Err(err) if err.kind() == ErrorKind::NotFound => Ok(()),
        Err(err) => Err(err).context("failed to clear daemon recovery file"),
    }
}