Skip to content

Commit

Permalink
Merge branch 'master' into fmartingr/issue665
Browse files Browse the repository at this point in the history
  • Loading branch information
fmartingr authored Aug 6, 2023
2 parents a33876d + 2e1016e commit 3912173
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/_buildx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ jobs:
- name: Prepare master push tags
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
echo "tag_flags=--tag ${{ github.ref }}" >> $GITHUB_ENV
REPO=ghcr.io/${{ github.repository }}
TAG=$(git describe --tags)
if [ -z "$(git tag --points-at HEAD)" ]
if [ -z "$(git tag --points-at HEAD)" ] || [ "$TAG" == *"rc"* ]
then
TAG2="dev"
else
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ jobs:
uses: ./.github/workflows/_gorelease.yml
call-buildx:
needs: call-gorelease
# only build on pull requests from the same repo for now
if: github.event.pull_request.head.repo.full_name == github.repository
uses: ./.github/workflows/_buildx.yml
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![IC](https://github.com/go-shiori/shiori/actions/workflows/push.yml/badge.svg?branch=master)](https://github.com/go-shiori/shiori/actions/workflows/push.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-shiori/shiori)](https://goreportcard.com/report/github.com/go-shiori/shiori)
[![#[email protected]](https://img.shields.io/badge/irc-%23shiori-orange)](https://web.libera.chat/#shiori)
[![#shiori-general:matrix.org](https://img.shields.io/badge/matrix-%23shiori-orange)](https://matrix.to/#/#shiori:matrix.org)
[![Containers](https://img.shields.io/static/v1?label=Container&message=Images&color=1488C6&logo=docker)](https://github.com/go-shiori/shiori/pkgs/container/shiori)

Expand Down
25 changes: 13 additions & 12 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func initShiori(ctx context.Context, cmd *cobra.Command) (*config.Config, *confi
logger.WithError(err).Fatal("error creating data directory")
}

db, err := openDatabase(ctx, cfg.Database.DBMS, cfg.Database.URL)
db, err := openDatabase(logger, ctx, cfg)
if err != nil {
logger.WithError(err).Fatal("error opening database")
}
Expand Down Expand Up @@ -124,23 +124,24 @@ func initShiori(ctx context.Context, cmd *cobra.Command) (*config.Config, *confi
return cfg, dependencies
}

func openDatabase(ctx context.Context, dbms, dbURL string) (database.DB, error) {
if dbURL != "" {
return database.Connect(ctx, dbURL)
func openDatabase(logger *logrus.Logger, ctx context.Context, cfg *config.Config) (database.DB, error) {
if cfg.Database.URL != "" {
return database.Connect(ctx, cfg.Database.URL)
}
if dbms == "mysql" {

if cfg.Database.DBMS != "" {
logger.Warnf("The use of SHIORI_DBMS is deprecated and will be removed in the future. Please migrate to SHIORI_DATABASE_URL instead.")
}

// TODO remove this the moment DBMS is deprecated
if cfg.Database.DBMS == "mysql" {
return openMySQLDatabase(ctx)
}
if dbms == "postgresql" {
if cfg.Database.DBMS == "postgresql" {
return openPostgreSQLDatabase(ctx)
}
return openSQLiteDatabase(ctx)
}

func openSQLiteDatabase(ctx context.Context) (database.DB, error) {
dataDir := os.Getenv("SHIORI_DIR")
dbPath := fp.Join(dataDir, "shiori.db")
return database.OpenSQLiteDatabase(ctx, dbPath)
return database.OpenSQLiteDatabase(ctx, fp.Join(cfg.Storage.DataDir, "shiori.db"))
}

func openMySQLDatabase(ctx context.Context) (database.DB, error) {
Expand Down
3 changes: 3 additions & 0 deletions internal/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/go-shiori/shiori/internal/http"
"github.com/go-shiori/shiori/internal/model"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -63,6 +64,8 @@ func newServerCommandHandler() func(cmd *cobra.Command, args []string) {
cfg.Http.ServeWebUI = serveWebUI
cfg.Http.SecretKey = secretKey

dependencies.Log.Infof("Starting Shiori v%s", model.BuildVersion)

server := http.NewHttpServer(dependencies.Log).Setup(cfg, dependencies)

if err := server.Start(ctx); err != nil {
Expand Down
1 change: 0 additions & 1 deletion internal/core/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func RemoveUTMParams(url string) (string, error) {
}
}

tmp.Fragment = ""
tmp.RawQuery = queryEncodeWithoutEmptyValues(queries)
return tmp.String(), nil
}
3 changes: 0 additions & 3 deletions internal/http/routes/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ type LegacyAPIRoutes struct {
func (r *LegacyAPIRoutes) convertHttprouteParams(params gin.Params) httprouter.Params {
routerParams := httprouter.Params{}
for _, p := range params {
if p.Key == "filepath" {
r.logger.WithField("value", p.Value).Error("filepath")
}
routerParams = append(routerParams, httprouter.Param{
Key: p.Key,
Value: p.Value,
Expand Down
4 changes: 2 additions & 2 deletions internal/webserver/handler-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h

if payload.Async {
go func() {
bookmark, err := downloadBookmarkContent(book, h.DataDir, r, !userHasDefinedTitle, book.Excerpt != "")
bookmark, err := downloadBookmarkContent(book, h.DataDir, r, userHasDefinedTitle, book.Excerpt != "")
if err != nil {
log.Printf("error downloading boorkmark: %s", err)
return
Expand All @@ -249,7 +249,7 @@ func (h *Handler) ApiInsertBookmark(w http.ResponseWriter, r *http.Request, ps h
} else {
// Workaround. Download content after saving the bookmark so we have the proper database
// id already set in the object regardless of the database engine.
book, err = downloadBookmarkContent(book, h.DataDir, r, !userHasDefinedTitle, book.Excerpt != "")
book, err = downloadBookmarkContent(book, h.DataDir, r, userHasDefinedTitle, book.Excerpt != "")
if err != nil {
log.Printf("error downloading boorkmark: %s", err)
} else if _, err := h.DB.SaveBookmarks(ctx, false, *book); err != nil {
Expand Down

0 comments on commit 3912173

Please sign in to comment.