diff --git a/lib/config.go b/lib/config.go index a7bace7..859e36e 100644 --- a/lib/config.go +++ b/lib/config.go @@ -189,6 +189,13 @@ func (cfg *Config) init() error { cfg.SourcePath = filepath.Clean(cfg.SourcePath) + // Resolve symlinks + re, err := filepath.EvalSymlinks(cfg.SourcePath) + if err != nil { + return errors.New("failed to resolve symlink " + err.Error()) + } + cfg.SourcePath = re + // Sanity check to prevent people from uploading their entire disk. // The returned path from filepath.Clean ends in a slash only if it represents // a root directory, such as "/" on Unix or `C:\` on Windows. @@ -251,7 +258,7 @@ func (cfg *Config) init() error { } // load additional config (routes) from file if it exists. - err := cfg.loadFileConfig() + err = cfg.loadFileConfig() if err != nil { return fmt.Errorf("failed to load config from %s: %s", cfg.ConfigFile, err) }