mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-13 06:40:41 +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/commander"
|
||||||
"github.com/smira/flag"
|
"github.com/smira/flag"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func aptlyAPIServe(cmd *commander.Command, args []string) error {
|
func aptlyAPIServe(cmd *commander.Command, args []string) error {
|
||||||
@@ -18,6 +19,10 @@ func aptlyAPIServe(cmd *commander.Command, args []string) error {
|
|||||||
return commander.ErrCommandError
|
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()
|
listen := context.Flags().Lookup("listen").Value.String()
|
||||||
|
|
||||||
fmt.Printf("\nStarting web server at: %s (press Ctrl+C to quit)...\n", listen)
|
fmt.Printf("\nStarting web server at: %s (press Ctrl+C to quit)...\n", listen)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func aptlyServe(cmd *commander.Command, args []string) error {
|
func aptlyServe(cmd *commander.Command, args []string) error {
|
||||||
@@ -22,6 +23,10 @@ func aptlyServe(cmd *commander.Command, args []string) error {
|
|||||||
return commander.ErrCommandError
|
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 {
|
if context.CollectionFactory().PublishedRepoCollection().Len() == 0 {
|
||||||
fmt.Printf("No published repositories, unable to serve.\n")
|
fmt.Printf("No published repositories, unable to serve.\n")
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user