pub async fn partial_wallet_backup<P: AsRef<Path>>(current_db: P, backup_path: P) -> Result<(), WalletStorageError> {
    // Copy the current db to the backup path
    let db_path = current_db
        .as_ref()
        .to_str()
        .ok_or_else(|| WalletStorageError::InvalidUnicodePath)?;
    let backup_path = backup_path
        .as_ref()
        .to_str()
        .ok_or_else(|| WalletStorageError::InvalidUnicodePath)?;
    std::fs::copy(db_path, backup_path)
        .map_err(|_| WalletStorageError::FileError("Could not copy database file for backup".to_string()))?;

    // open a connection and clear the Comms Private Key
    let connection = run_migration_and_create_sqlite_connection(backup_path)?;
    let db = WalletDatabase::new(WalletSqliteDatabase::new(connection, None)?);
    db.clear_comms_secret_key().await?;

    Ok(())
}
/// This function will copy a wallet database to the provided path and then clear the CommsPrivateKey from the database.
This function will copy a wallet database to the provided path and then clear the CommsPrivateKey from the database.
This function will copy a wallet database to the provided path and then clear the CommsPrivateKey from the database .
pub async fn partial_wallet_backup<P: AsRef<Path>>(current_db: P, backup_path: P) -> Result<(), WalletStorageError> {
    // Copy the current db to the backup path
    let db_path = current_db
        .as_ref()
        .to_str()
        .ok_or_else(|| WalletStorageError::InvalidUnicodePath)?;
    let backup_path = backup_path
        .as_ref()
        .to_str()
        .ok_or_else(|| WalletStorageError::InvalidUnicodePath)?;
    std::fs::copy(db_path, backup_path)
        .map_err(|_| WalletStorageError::FileError("Could not copy database file for backup".to_string()))?;
    // open a connection and clear the Comms Private Key
    let connection = run_migration_and_create_sqlite_connection(backup_path)?;
    let db = WalletDatabase::new(WalletSqliteDatabase::new(connection, None)?);
    db.clear_comms_secret_key().await?;
    Ok(())
}
pub async fn partial_wallet_backup < P : AsRef < Path > > ( current_db : P , backup_path : P ) -> Result < ( ) , WalletStorageError > { // Copy the current db to the backup path let db_path = current_db . as_ref ( ) . to_str ( ) . ok_or_else ( | | WalletStorageError :: InvalidUnicodePath ) ? ; let backup_path = backup_path . as_ref ( ) . to_str ( ) . ok_or_else ( | | WalletStorageError :: InvalidUnicodePath ) ? ; std :: fs :: copy ( db_path , backup_path ) . map_err ( | _ | WalletStorageError :: FileError ( " " . to_string ( ) ) ) ? ; // open a connection and clear the Comms Private Key let connection = run_migration_and_create_sqlite_connection ( backup_path ) ? ; let db = WalletDatabase :: new ( WalletSqliteDatabase :: new ( connection , None ) ? ) ; db . clear_comms_secret_key ( ) . await ? ; Ok ( ( ) ) }
This function will copy a wallet database to the provided path and then clear the CommsPrivateKey from the database.
This function will copy a wallet database to the provided path and then clear the CommsPrivateKey from the database .
current_db
P
backup_path
P
current_db
P
backup_path
P