From f3902f800f7e0c25564b42f4ecd1ff8a1d0e6182 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sun, 7 Jul 2019 18:27:50 +0200 Subject: [PATCH] Remove migration subcommand --- src/config.rs | 8 -------- src/main.rs | 37 ++----------------------------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/src/config.rs b/src/config.rs index 66d02a3..e0a848c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -46,14 +46,6 @@ pub(crate) struct Opt { )] /// The logfile pub(crate) logfile: PathBuf, - #[structopt(subcommand)] - pub(crate) migrate: Option, -} - -#[derive(StructOpt, Debug, Clone, Copy)] -pub(crate) enum Migration { - #[structopt(name = "migrate-commit-count")] - CacheCommitCount, } pub(crate) fn init() -> Result<()> { diff --git a/src/main.rs b/src/main.rs index ca755d7..9f63d4b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,6 @@ mod statics; use crate::{ cache::CacheState, - config::Migration, error::{Error, Result}, service::{Bitbucket, FormService, GitHub, Gitlab, Service}, statics::{CLIENT, CSS, FAVICON, OPT, REPO_COUNT, VERSION_INFO}, @@ -35,7 +34,7 @@ use git2::Repository; use number_prefix::{NumberPrefix, Prefixed, Standalone}; use std::{ borrow::Cow, - fs::{create_dir_all, read_dir, rename}, + fs::create_dir_all, path::Path, process::Command, sync::atomic::Ordering, @@ -372,39 +371,7 @@ fn start_server() -> Result<()> { .run()?) } -fn migrate_cache() -> Result<()> { - let mut backup_cache = OPT.cachedir.clone(); - backup_cache.set_extension("bak"); - rename(&OPT.cachedir, backup_cache)?; - let outdir = OPT.outdir.display().to_string(); - let cachedir = OPT.cachedir.display().to_string(); - for service in read_dir(&OPT.outdir)? { - let service = service?; - for namespace in read_dir(service.path())? { - let namespace = namespace?; - for repo in read_dir(namespace.path())? { - let repo_path = repo?.path().display().to_string(); - let repo_path: String = - repo_path - .split(&outdir) - .fold(String::new(), |mut acc, next| { - acc.push_str(next); - acc - }); - println!("{}", repo_path); - hoc(&repo_path, &outdir, &cachedir)?; - } - } - } - Ok(()) -} - fn main() -> Result<()> { config::init()?; - match &OPT.migrate { - None => start_server(), - Some(migration) => match migration { - Migration::CacheCommitCount => migrate_cache(), - }, - } + start_server() }