adding more server/client communication commands, need to fix echo path params

This commit is contained in:
2020-06-08 20:55:34 -04:00
parent b2238657c8
commit c2e74ce7f4
10 changed files with 111 additions and 33 deletions

View File

@@ -6,29 +6,30 @@ import (
)
// CheckFileTypes allows the server and client to do some basic validation on adding/removing file types to the toml file
func CheckFileTypes(input string, inputType string, ignores FileTypes) error {
// Since Ignore, NoCompress, and Locked have the same structure, you can provide the exclude list for any of them and this func will check that list to see if it already exists
func CheckFileTypes(input string, inputType string, excludeList FileTypes) error {
switch inputType {
case "file":
fileExt := filepath.Ext(input) // TODO more sanity checking on ext
for _, ignoredExt := range ignores.Exts {
if fileExt == ignoredExt {
return fmt.Errorf("file ext is on ignored list, cannot add file with file ext %s", fileExt)
for _, suppliedExt := range excludeList.Exts {
if fileExt == suppliedExt { //Check to make sure the file is not already on the list via ext
return fmt.Errorf("file ext is on excludeList, cannot add file ext %s", fileExt)
}
}
for _, ignoredFile := range ignores.Files {
if input == ignoredFile {
return fmt.Errorf("file name is on ignored list, cannot add file with name %s", input)
for _, suppliedFile := range excludeList.Files {
if input == suppliedFile {
return fmt.Errorf("file name is on excludeList, cannot add file with name %s", input)
}
}
case "folder":
for _, ignoredFolder := range ignores.Folders {
if input == ignoredFolder {
return fmt.Errorf("folder name is on the ignored list, cannot add folder with name %s", input)
for _, suppliedFolder := range excludeList.Folders {
if input == suppliedFolder {
return fmt.Errorf("folder name is on the excludeList, cannot add folder with name %s", input)
}
}
case "wildcard":
for _, ignoredExt := range ignores.Exts {
if input == ignoredExt {
for _, suppliedExt := range excludeList.Exts {
if input == suppliedExt {
return fmt.Errorf("cannot add wildcard, since that ext is already added to the ignore config %s", input)
}
}