mirror of
https://github.com/agersant/polaris
synced 2024-11-10 02:04:13 +00:00
Remove some usage of anyhow
This commit is contained in:
parent
edc7170b89
commit
98d00d261d
3 changed files with 32 additions and 8 deletions
|
@ -1,4 +1,3 @@
|
|||
use anyhow::Result;
|
||||
use log::{error, info};
|
||||
use std::time;
|
||||
|
||||
|
@ -7,14 +6,29 @@ mod collector;
|
|||
mod inserter;
|
||||
mod traverser;
|
||||
|
||||
use super::*;
|
||||
use crate::app::index::Index;
|
||||
use crate::app::vfs;
|
||||
use crate::db;
|
||||
|
||||
use cleaner::Cleaner;
|
||||
use collector::Collector;
|
||||
use inserter::Inserter;
|
||||
use traverser::Traverser;
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
IndexClean(#[from] cleaner::Error),
|
||||
#[error(transparent)]
|
||||
Database(#[from] diesel::result::Error),
|
||||
#[error(transparent)]
|
||||
DatabaseConnection(#[from] db::Error),
|
||||
#[error(transparent)]
|
||||
Vfs(#[from] vfs::Error),
|
||||
}
|
||||
|
||||
impl Index {
|
||||
pub fn update(&self) -> Result<()> {
|
||||
pub fn update(&self) -> Result<(), Error> {
|
||||
let start = time::Instant::now();
|
||||
info!("Beginning library index update");
|
||||
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
use anyhow::*;
|
||||
use diesel::prelude::*;
|
||||
use rayon::prelude::*;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::app::vfs;
|
||||
use crate::db::{directories, songs, DB};
|
||||
use crate::db::{self, directories, songs, DB};
|
||||
|
||||
const INDEX_BUILDING_CLEAN_BUFFER_SIZE: usize = 500; // Deletions in each transaction
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
Database(#[from] diesel::result::Error),
|
||||
#[error(transparent)]
|
||||
DatabaseConnection(#[from] db::Error),
|
||||
#[error(transparent)]
|
||||
ThreadPoolBuilder(#[from] rayon::ThreadPoolBuildError),
|
||||
#[error(transparent)]
|
||||
Vfs(#[from] vfs::Error),
|
||||
}
|
||||
|
||||
pub struct Cleaner {
|
||||
db: DB,
|
||||
vfs_manager: vfs::Manager,
|
||||
|
@ -18,7 +29,7 @@ impl Cleaner {
|
|||
Self { db, vfs_manager }
|
||||
}
|
||||
|
||||
pub fn clean(&self) -> Result<()> {
|
||||
pub fn clean(&self) -> Result<(), Error> {
|
||||
let vfs = self.vfs_manager.get_vfs()?;
|
||||
|
||||
let all_directories: Vec<String> = {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use anyhow::Result;
|
||||
use simplelog::LevelFilter;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
@ -28,7 +27,7 @@ impl Manager {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn parse(&self, input: &[String]) -> Result<CLIOptions> {
|
||||
pub fn parse(&self, input: &[String]) -> Result<CLIOptions, getopts::Fail> {
|
||||
let matches = self.protocol.parse(input)?;
|
||||
|
||||
Ok(CLIOptions {
|
||||
|
|
Loading…
Reference in a new issue