starting on the commit logic

This commit is contained in:
2020-06-21 22:26:03 -04:00
parent 1ec7b436da
commit e4ac7f70e6
7 changed files with 90 additions and 28 deletions

View File

@@ -8,21 +8,9 @@ import (
"os"
"strings"
logger "github.com/apsdehal/go-logger"
clientconfig "github.com/deranjer/gvc/client/clientconfig"
)
var log *logger.Logger
func init() {
var err error
log, err = logger.New("utilities logger", 1, os.Stdout)
if err != nil {
panic(err)
}
log.SetFormat("[%{module}] [%{level}] %{message}")
log.Info("Utilities logger Created")
}
// CompressIntArray compresses an array of integers into a buffer
func CompressIntArray(arry []int64, compressionBuffer *bytes.Buffer) (float64, error) {
buf := new(bytes.Buffer)
@@ -83,22 +71,28 @@ func InitiateDirectory(directory string) {
// For the keys-folder we need to check if the folder exists...
checkDir, err := IsDirectory(directory)
if err != nil {
log.ErrorF("Error checking for "+directory+" directory: %s\r\n", err)
fmt.Println("Error checking for "+directory+" directory: %s\r\n", err)
panic(err)
}
if checkDir == true {
log.Warning(directory + " already exists")
fmt.Println(directory + " already exists")
} else {
// Create the directory.
log.Info("Creating " + directory)
fmt.Println("Creating " + directory)
err = CreateDirectory(directory)
if err != nil {
log.ErrorF("Error creating the folder %s\r\n", err)
fmt.Println("Error creating the folder %s\r\n", err)
panic(err)
}
}
}
// CreateInitialCommit copies the files over and compresses them if they are not in the NoCompress struct
func CreateInitialCommit(conf *clientconfig.Gvcconfig) {
//Need to deduplicate so we aren't storing duplicates of files, storing all the files in one folder won't work, will need something like git
}
func IsDirectory(path string) (bool, error) {
s, err := os.Stat(path) // returns an error if the path does not exist.