mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Let portmaster-start exit with an error if index update fails
This commit is contained in:
parent
088fef6f55
commit
504c753a9b
5 changed files with 12 additions and 22 deletions
|
@ -46,19 +46,6 @@ fi
|
|||
# build tools
|
||||
EXTRA_LD_FLAGS=""
|
||||
if [[ $GOOS == "windows" ]]; then
|
||||
# checks
|
||||
if [[ $CC_FOR_windows_amd64 == "" ]]; then
|
||||
echo "ENV variable CC_FOR_windows_amd64 (c compiler) is not set. Please set it to the cross compiler you want to use for compiling for windows_amd64"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $CXX_FOR_windows_amd64 == "" ]]; then
|
||||
echo "ENV variable CXX_FOR_windows_amd64 (c++ compiler) is not set. Please set it to the cross compiler you want to use for compiling for windows_amd64"
|
||||
exit 1
|
||||
fi
|
||||
# compilers
|
||||
export CC=$CC_FOR_windows_amd64
|
||||
export CXX=$CXX_FOR_windows_amd64
|
||||
# custom
|
||||
export CGO_ENABLED=1
|
||||
EXTRA_LD_FLAGS='-H windowsgui' # Hide console window by default (but we attach to parent console if available)
|
||||
# generate resource.syso for windows metadata / icon
|
||||
|
|
|
@ -41,8 +41,8 @@ var (
|
|||
Use: "portmaster-start",
|
||||
Short: "Start Portmaster components",
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
|
||||
if err := configureDataRoot(); err != nil {
|
||||
mustLoadIndex := cmd == updatesCmd
|
||||
if err := configureDataRoot(mustLoadIndex); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ func initCobra() {
|
|||
portlog.SetLogLevel(portlog.CriticalLevel)
|
||||
}
|
||||
|
||||
func configureDataRoot() error {
|
||||
func configureDataRoot(mustLoadIndex bool) error {
|
||||
// The data directory is not
|
||||
// check for environment variable
|
||||
// PORTMASTER_DATA
|
||||
|
@ -176,8 +176,7 @@ func configureDataRoot() error {
|
|||
// Beta: true,
|
||||
// })
|
||||
|
||||
updateRegistryIndex()
|
||||
return nil
|
||||
return updateRegistryIndex(mustLoadIndex)
|
||||
}
|
||||
|
||||
func configureLogging() error {
|
||||
|
@ -196,10 +195,13 @@ func configureLogging() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func updateRegistryIndex() {
|
||||
func updateRegistryIndex(mustLoadIndex bool) error {
|
||||
err := registry.LoadIndexes(context.Background())
|
||||
if err != nil {
|
||||
log.Printf("WARNING: error loading indexes: %s\n", err)
|
||||
if mustLoadIndex {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = registry.ScanStorage("")
|
||||
|
@ -208,6 +210,7 @@ func updateRegistryIndex() {
|
|||
}
|
||||
|
||||
registry.SelectVersions()
|
||||
return nil
|
||||
}
|
||||
|
||||
func detectInstallationDir() string {
|
||||
|
|
|
@ -188,7 +188,7 @@ func runAndRestart(opts *Options, args []string) error {
|
|||
// if we are constantly failing or a restart was requested
|
||||
// try to update the resources.
|
||||
log.Printf("updating registry index")
|
||||
updateRegistryIndex()
|
||||
updateRegistryIndex(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ var showCmd = &cobra.Command{
|
|||
Use: "show",
|
||||
PersistentPreRunE: func(*cobra.Command, []string) error {
|
||||
// all show sub-commands need the data-root but no logging.
|
||||
return configureDataRoot()
|
||||
return configureDataRoot(false)
|
||||
},
|
||||
Short: "Show the command to run a Portmaster component yourself",
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ var versionCmd = &cobra.Command{
|
|||
if showAllVersions {
|
||||
// if we are going to show all component versions
|
||||
// we need the dataroot to be configured.
|
||||
if err := configureDataRoot(); err != nil {
|
||||
if err := configureDataRoot(false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue