Skip to content

Commit

Permalink
add additional handling for missing databases
Browse files Browse the repository at this point in the history
  • Loading branch information
RobBrazier committed Nov 2, 2024
1 parent 5f27ace commit bdeb8e9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/source/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"errors"
"fmt"
"log/slog"
"os"
"strings"

"github.com/RobBrazier/readflow/internal"
"github.com/jmoiron/sqlx"
"github.com/spf13/cobra"
"github.com/spf13/viper"
_ "modernc.org/sqlite"
)
Expand All @@ -26,6 +28,9 @@ type chaptersRow struct {
const CHAPTERS_COLUMN = "columns.chapter"

func (s *databaseSource) getReadOnlyDbString(file string) string {
if _, err := os.Stat(file); errors.Is(err, os.ErrNotExist) {
cobra.CheckErr(fmt.Sprintf("Unable to access database %s. Is the path correct?", file))
}
return fmt.Sprintf("file:%s?mode=ro", file)
}

Expand Down

0 comments on commit bdeb8e9

Please sign in to comment.