Abort serve command if rootDir is inaccesible

This commit is contained in:
jola5 committed 2017-02-15 20:18:47 +01:00
1 parent ab0d77f6f9
commit b948180b4e
2 files changed
+10

No files matched your search

+5
View File
@@ -12,6 +12,7 @@ import (
"os"
"sort"
"strings"
"golang.org/x/sys/unix"
)
func aptlyServe(cmd *commander.Command, args []string) error {
@@ -22,6 +23,10 @@ func aptlyServe(cmd *commander.Command, args []string) error {
return commander.ErrCommandError
}
if unix.Access(context.Config().RootDir, unix.W_OK) != nil {
return fmt.Errorf("Configured rootDir '%s' inaccesible, check access rights", context.Config().RootDir)
}
if context.CollectionFactory().PublishedRepoCollection().Len() == 0 {
fmt.Printf("No published repositories, unable to serve.\n")
return nil