Browse Source

Fix a few sync and logging bugs.

tags/v0.3.4
Thomas Kerber 1 year ago
parent
commit
ad7a28c3e8
Signed by: Thomas Kerber <t.kerber@ed.ac.uk> GPG Key ID: 8489B911F9ED617B
10 changed files with 976 additions and 997 deletions
  1. 161
    160
      Cargo.lock
  2. 783
    804
      Cargo.nix
  3. 4
    4
      Cargo.toml
  4. 4
    2
      default.nix
  5. 1
    1
      goblin-core/Cargo.toml
  6. 1
    1
      goblin-core/src/state.rs
  7. 5
    0
      hydra.nix
  8. 6
    4
      src/cfg.rs
  9. 11
    20
      src/log.rs
  10. 0
    1
      src/main.rs

+ 161
- 160
Cargo.lock
File diff suppressed because it is too large
View File


+ 783
- 804
Cargo.nix
File diff suppressed because it is too large
View File


+ 4
- 4
Cargo.toml View File

@@ -1,6 +1,6 @@
[package]
name = "goblin"
version = "0.3.3"
version = "0.3.4"
authors = ["Thomas Kerber <tk@drwx.org>"]
description = "Version controlled password management."
publish = false
@@ -13,8 +13,8 @@ weak-scrypt = ["goblin-core/weak-scrypt"]
clap = "2.26"
clipboard = "0.4.4"
getch = "0.2"
goblin-core = {path="goblin-core"}
log = "0.3"
goblin-core = { path = "goblin-core" }
log = { version = "0.4", features = ["release_max_level_info"] }
rand = "0.3"
rpassword = "1.0"
term = "0.4"
@@ -22,4 +22,4 @@ atty = "0.2"
serde = "1.0"
serde_json = "1.0"
chrono = "0.4"
ssh2 = {version="0.3", optional=true}
ssh2 = { version = "0.3", optional = true }

+ 4
- 2
default.nix View File

@@ -1,6 +1,8 @@
with import <nixpkgs> { };
{ nixpkgs ? import <nixpkgs> }:

with nixpkgs { };

((callPackage ./Cargo.nix { }).goblin { }).override {
release = false;
crateOverrides = defaultCrateOverrides // {
libgpg-error-sys = attrs: {
postFixup = ''

+ 1
- 1
goblin-core/Cargo.toml View File

@@ -1,6 +1,6 @@
[package]
name = "goblin-core"
version = "0.3.3"
version = "0.3.4"
authors = ["Thomas Kerber <tk@drwx.org>"]
publish = false


+ 1
- 1
goblin-core/src/state.rs View File

@@ -790,7 +790,7 @@ impl Merge {
'outer: for (i, h) in hashes.iter().enumerate() {
for h2 in hashes.iter() {
if h == h2 {
continue 'outer;
continue;
}
let mut seen = HashSet::new();
seen.insert(*h2);

+ 5
- 0
hydra.nix View File

@@ -0,0 +1,5 @@
{ nixpkgs ? import <nixpkgs> }:

{
goblin = import ./. { inherit nixpkgs; };
}

+ 6
- 4
src/cfg.rs View File

@@ -2,7 +2,8 @@ use atty;
use clap::ArgMatches;
use err::{Error, Result};
use goblin_core::{VaultLocation, ZeroBox};
use log;
use log::Logger;
use log_crate;
use rpassword::prompt_password_stdout;
use std::env::var_os;
use std::ffi::{OsStr, OsString};
@@ -35,8 +36,9 @@ impl Config {
None
},
};
log::Builder({
use LogLevelFilter::*;
log_crate::set_logger(&Logger).expect("Logger initialization failed!");
log_crate::set_max_level({
use log_crate::LevelFilter::*;
match cfg.verbosity {
i if i <= -2 => Off,
-1 => Error,
@@ -45,7 +47,7 @@ impl Config {
2 => Debug,
_ => Trace,
}
}).init();
});
Ok(cfg)
}


+ 11
- 20
src/log.rs View File

@@ -1,23 +1,11 @@
use log_crate::{Log, LogLevel, LogLevelFilter, LogMetadata, LogRecord,
MaxLogLevelFilter, set_logger};
use log_crate::LogLevel::*;
use log_crate::{Log, Level, Metadata, Record};
use log_crate::Level::*;
use std::io::Write;
use term::{BRIGHT_BLACK, BRIGHT_RED, Bold, RED, Term, WHITE};

pub struct Builder(pub LogLevelFilter);
pub struct Logger;

impl Builder {
pub fn init(self) {
set_logger(|f| {
f.set(self.0);
Box::new(Logger(f))
}).expect("failed to initialize logging");
}
}

struct Logger(MaxLogLevelFilter);

fn level_color<O: Write>(term: &mut Term<O>, level: LogLevel) {
fn level_color<O: Write>(term: &mut Term<O>, level: Level) {
match level {
Error => {
term.fg(BRIGHT_RED);
@@ -38,12 +26,11 @@ fn level_color<O: Write>(term: &mut Term<O>, level: LogLevel) {
}

impl Log for Logger {
fn enabled(&self, metadata: &LogMetadata) -> bool {
return metadata.level() <= self.0.get() &&
metadata.target().starts_with("goblin");
fn enabled(&self, metadata: &Metadata) -> bool {
return metadata.target().starts_with("goblin");
}

fn log(&self, record: &LogRecord) {
fn log(&self, record: &Record) {
if !self.enabled(record.metadata()) {
return;
}
@@ -67,4 +54,8 @@ impl Log for Logger {
eprintln!(" {}", record.args());
}
}

fn flush(&self) {
Term::stderr().flush();
}
}

+ 0
- 1
src/main.rs View File

@@ -23,7 +23,6 @@ mod args;

use clap::ArgMatches;
use err::Result;
use log_crate::LogLevelFilter;
use std::collections::HashMap;
use std::process::exit;


Loading…
Cancel
Save