added server logging to file, added logging and formatting to info and lock commands
This commit is contained in:
		@@ -2,7 +2,6 @@ package engine
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/deranjer/gvc/common"
 | 
			
		||||
@@ -28,6 +27,10 @@ func (Server *GVCServer) GetInfo(context echo.Context) error {
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if repoInfo.Repo.RepoName == "" {
 | 
			
		||||
		return echo.NewHTTPError(http.StatusNotFound, "repo apparently not found")
 | 
			
		||||
	}
 | 
			
		||||
	Server.Echo.Logger.Infof("returning information about repo: %s", repo)
 | 
			
		||||
	return context.JSONPretty(http.StatusAccepted, repoInfo, " ")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -36,16 +39,18 @@ func (Server *GVCServer) LockFile(context echo.Context) error {
 | 
			
		||||
	fileType := context.Param("type")
 | 
			
		||||
	fileName := context.Param("name")
 | 
			
		||||
	repoName := context.Param("repo")
 | 
			
		||||
	fmt.Printf("Lockfile: %s %s %s", repoName, fileType, fileName)
 | 
			
		||||
	Server.Echo.Logger.Infof("Lockfile: %s %s %s", repoName, fileType, fileName)
 | 
			
		||||
	var locked common.FileTypes
 | 
			
		||||
	var index int
 | 
			
		||||
	for i, repo := range Server.Config.Repos {
 | 
			
		||||
		if repo.RepoName == repoName {
 | 
			
		||||
			index = i
 | 
			
		||||
			locked = Server.Config.Repos[i].Locked
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	err := common.CheckFileTypes(fileName, fileType, locked) // making sure fi/f/wc is not already locked or cannot be locked.
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("failed checking file lock: %s", err)
 | 
			
		||||
		return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed checking file lock: %s", err))
 | 
			
		||||
	}
 | 
			
		||||
	switch fileType {
 | 
			
		||||
	case "file":
 | 
			
		||||
@@ -58,12 +63,13 @@ func (Server *GVCServer) LockFile(context echo.Context) error {
 | 
			
		||||
		fmt.Println("Wildcard: ", fileName)
 | 
			
		||||
		locked.Exts = append(locked.Exts, fileName)
 | 
			
		||||
	}
 | 
			
		||||
	fmt.Println("Locked: ", locked)                                 // TODO!!!!!!!!!!!! Write this to conf
 | 
			
		||||
	Server.Config.Repos[index].Locked = locked
 | 
			
		||||
	Server.Echo.Logger.Infof("server attempting to lock file: %s of type %s", fileName, fileType)
 | 
			
		||||
	err = store.Save(serverconfig.DefaultConfigPath, Server.Config) // Save our new default config back to TOML so it can be read in
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Fatalf("unable to save config to toml file: %s", err)
 | 
			
		||||
		return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("server unable to save lock to server: %s", err))
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
	return context.String(http.StatusAccepted, "file locked on server")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Refresh sends all updated information to client (like git fetch)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user