mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-04 05:10:40 +00:00
Abort serve command if rootDir is inaccesible
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/smira/commander"
|
||||
"github.com/smira/flag"
|
||||
"net/http"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func aptlyAPIServe(cmd *commander.Command, args []string) error {
|
||||
@@ -18,6 +19,10 @@ func aptlyAPIServe(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)
|
||||
}
|
||||
|
||||
listen := context.Flags().Lookup("listen").Value.String()
|
||||
|
||||
fmt.Printf("\nStarting web server at: %s (press Ctrl+C to quit)...\n", listen)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user