fix: avoid runtime error when list is empty

This commit is contained in:
Roxie Gibson 2021-08-02 00:37:23 +01:00
parent 4ae5e6123d
commit 9d621404fd
Signed by untrusted user: roxxers
GPG Key ID: 5D0140EDEE123F4D

View File

@ -100,7 +100,8 @@ func (a AppFiles) GetServers() []string {
func LoadAppFiles(servers ...string) (AppFiles, error) {
appFiles := make(AppFiles)
if len(servers) == 1 && servers[0] == "" {
if len(servers) == 1 {
if servers[0] == "" {
// Empty servers flag, one string will always be passed
var err error
servers, err = getAllFoldersInDirectory(ABRA_SERVER_FOLDER)
@ -108,6 +109,7 @@ func LoadAppFiles(servers ...string) (AppFiles, error) {
return nil, err
}
}
}
for _, server := range servers {
serverDir := path.Join(ABRA_SERVER_FOLDER, server)
files, err := getAllFilesInDirectory(serverDir)