diff --git a/cache/sa.go b/cache/sa.go index 661de85..129cd7d 100644 --- a/cache/sa.go +++ b/cache/sa.go @@ -40,7 +40,6 @@ func IsBanned(key string) (bool, time.Time) { // this key is still banned return true, item.Expires - } func SetBanned(key string, hours int) error { diff --git a/config/config.go b/config/config.go index 980d18e..9813087 100644 --- a/config/config.go +++ b/config/config.go @@ -2,7 +2,6 @@ package config import ( "fmt" - "github.com/json-iterator/go" "os" "github.com/l3uddz/crop/logger" @@ -38,18 +37,11 @@ var ( // Internal log = logger.GetLogger("cfg") - json = jsoniter.ConfigCompatibleWithStandardLibrary newOptionLen = 0 ) /* Public */ -func (cfg Configuration) ToJsonString() (string, error) { - c := viper.AllSettings() - bs, err := json.MarshalIndent(c, "", " ") - return string(bs), err -} - func Init(configFilePath string) error { // set package variables cfgPath = configFilePath @@ -101,7 +93,6 @@ func Init(configFilePath string) error { func ShowUsing() { log.Infof("Using %s = %q", stringutils.LeftJust("CONFIG", " ", 10), cfgPath) - } /* Private */ diff --git a/go.mod b/go.mod index 0e22d4f..92ed99c 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/go-cmd/cmd v1.2.0 github.com/golang/protobuf v1.4.0 // indirect - github.com/json-iterator/go v1.1.9 + github.com/json-iterator/go v1.1.9 // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/mattn/go-colorable v0.1.6 // indirect github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect diff --git a/logger/log.go b/logger/log.go index c636f41..45d9b81 100644 --- a/logger/log.go +++ b/logger/log.go @@ -48,6 +48,7 @@ func Init(logLevel int, logFilePath string) error { logrus.WithError(err).Errorf("Failed initializing rotating file log to %q", logFilePath) return errors.Wrap(err, "failed initializing rotating file hook") } + logrus.AddHook(rotateFileHook) // set console formatter diff --git a/pathutils/file.go b/pathutils/file.go index 29c41bd..961ae23 100644 --- a/pathutils/file.go +++ b/pathutils/file.go @@ -1,13 +1,10 @@ package pathutils import ( - "github.com/l3uddz/crop/logger" "os" "path/filepath" ) -var log = logger.GetLogger("paths") - /* Public */ func GetCurrentBinaryPath() string { diff --git a/pathutils/find.go b/pathutils/find.go index 1a728b1..10661d5 100644 --- a/pathutils/find.go +++ b/pathutils/find.go @@ -1,12 +1,18 @@ package pathutils import ( + "github.com/l3uddz/crop/logger" + "os" "path/filepath" "strings" "time" ) +var ( + log = logger.GetLogger("paths") +) + type Path struct { Path string RealPath string @@ -47,12 +53,13 @@ func GetPathsInFolder(folder string, includeFiles bool, includeFolders bool, acc } if acceptFn != nil { - if acceptedPath := acceptFn(path); acceptedPath == nil { + acceptedPath := acceptFn(path) + if acceptedPath == nil { log.Tracef("Skipping rejected path: %s", path) return nil - } else { - finalPath = *acceptedPath } + + finalPath = *acceptedPath } foundPath := Path{ @@ -70,7 +77,6 @@ func GetPathsInFolder(folder string, includeFiles bool, includeFolders bool, acc size += uint64(info.Size()) return nil - }) if err != nil { diff --git a/runtime/runtime.go b/runtime/runtime.go index 946ac0f..19eab2c 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -1,7 +1,6 @@ package runtime var ( - // Build Vars Version string Timestamp string GitCommit string diff --git a/uploader/checker/size.go b/uploader/checker/size.go index f58626c..67fdc66 100644 --- a/uploader/checker/size.go +++ b/uploader/checker/size.go @@ -10,7 +10,6 @@ import ( type Size struct{} func (_ Size) Check(cfg *config.UploaderCheck, log *logrus.Entry, paths []pathutils.Path, size uint64) (bool, error) { - // Check Total Size if size > cfg.Limit { log.WithFields(logrus.Fields{ @@ -25,7 +24,6 @@ func (_ Size) Check(cfg *config.UploaderCheck, log *logrus.Entry, paths []pathut } func (_ Size) CheckFile(cfg *config.UploaderCheck, log *logrus.Entry, path pathutils.Path, size uint64) (bool, error) { - // Check Total Size if size > cfg.Limit { return true, nil