fix: Prevent nil errors on creating FileInfo structs

This commit is contained in:
Felix Pojtinger
2021-12-28 21:59:36 +01:00
parent eb74151c59
commit 7d5723f2e4
8 changed files with 55 additions and 31 deletions
+4 -6
View File
@@ -55,11 +55,11 @@ https://github.com/pojntfx/stfs`,
},
}
func Execute() {
func Execute() error {
// Get default working dir
home, err := os.UserHomeDir()
if err != nil {
panic(err)
return err
}
metadataPath := filepath.Join(home, ".local", "share", "stfs", "var", "lib", "stfs", "metadata.sqlite")
@@ -71,12 +71,10 @@ func Execute() {
rootCmd.PersistentFlags().StringP(signatureFlag, "s", config.NoneKey, fmt.Sprintf("Signature format to use (default %v, available are %v)", config.NoneKey, config.KnownSignatureFormats))
if err := viper.BindPFlags(rootCmd.PersistentFlags()); err != nil {
panic(err)
return err
}
viper.AutomaticEnv()
if err := rootCmd.Execute(); err != nil {
panic(err)
}
return rootCmd.Execute()
}
+1 -1
View File
@@ -236,7 +236,7 @@ var serveFTPCmd = &cobra.Command{
)
if viper.GetBool(verboseFlag) {
srv.Logger = &logging.JSONLogger{}
srv.Logger = jsonLogger
}
jsonLogger.Info("FTP server listening", map[string]interface{}{
+1
View File
@@ -158,6 +158,7 @@ var serveHTTPCmd = &cobra.Command{
http.FileServer(
afero.NewHttpFs(fs),
),
jsonLogger,
),
)
},
+3 -1
View File
@@ -3,5 +3,7 @@ package main
import "github.com/pojntfx/stfs/cmd/stfs/cmd"
func main() {
cmd.Execute()
if err := cmd.Execute(); err != nil {
panic(err)
}
}