Skip to content

Commit

Permalink
fix: fatal log will print to stderr instead (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
dubyte authored Dec 11, 2024
1 parent 278f6a5 commit 78af97c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0] - 2024-12-10

### Added

- pod container creation by @kulak

### Changed

- fail to start will log error on stderr in this case when book dir was not found.

## [1.2.0] - 2024-06-18

### Added
Expand Down
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"io"
"log"
"net/http"
"os"
"path/filepath"

"github.com/dubyte/dir2opds/internal/service"
Expand All @@ -46,19 +47,19 @@ func main() {
log.SetOutput(io.Discard)
}

fmt.Println(startValues())
var err error

// Use the absoluteCanonical path of the dir parm as the trustedRoot.
// helpfull avoid http trasversal. https://github.com/dubyte/dir2opds/issues/17
*dirRoot, err = absoluteCanonicalPath(*dirRoot)
absolutePath, err := absoluteCanonicalPath(*dirRoot)
if err != nil {
log.Fatal(err)
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}

log.Printf("%q will be used as your trusted root", *dirRoot)
log.Printf("%q will be used as your trusted root", absolutePath)

fmt.Println(startValues())

s := service.OPDS{TrustedRoot: *dirRoot, HideCalibreFiles: *calibre, HideDotFiles: *hideDotFiles, NoCache: *noCache}
s := service.OPDS{TrustedRoot: absolutePath, HideCalibreFiles: *calibre, HideDotFiles: *hideDotFiles, NoCache: *noCache}

http.HandleFunc("/", errorHandler(s.Handler))

Expand Down

0 comments on commit 78af97c

Please sign in to comment.