20 lines
574 B
Go
20 lines
574 B
Go
package validation
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.zervo.org/zervo/fileserver/internal/config"
|
|
"git.zervo.org/zervo/fileserver/internal/util"
|
|
)
|
|
|
|
// ValidateDirectories ensure the given directories meet the required criteria to be served.
|
|
// Any directory that doesn't meet the requirements gets removed from the slice.
|
|
func ValidateDirectories(dirs []config.Directory) {
|
|
for i, dir := range dirs {
|
|
exists, err := util.FileExists(dir.Path)
|
|
if !exists {
|
|
fmt.Printf("WARNING: The directory '%s' does not exist and will be delisted. %v", dir.Id, err)
|
|
dirs[i] = nil
|
|
}
|
|
}
|
|
}
|