b9f4c77a0ffb8905cc0c00a812bd0ddfd975958e

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(backend): settings query

Diff

 1diff --git a/server/backend/sqlite/sqlite.go b/server/backend/sqlite/sqlite.go
 2index 7ee17dfc404247f8f47ad856fa6e01cfb69484fb..e8df07ae12c17465fb8f7d9dfd1bfbf6376e2efd 100644
 3--- a/server/backend/sqlite/sqlite.go
 4+++ b/server/backend/sqlite/sqlite.go
 5@@ -6,7 +6,6 @@ import (
 6 	"fmt"
 7 	"os"
 8 	"path/filepath"
 9-	"strconv"
10 	"strings"
11 	"text/template"
12 
13@@ -101,7 +100,7 @@ func (d *SqliteBackend) AnonAccess() backend.AccessLevel {
14 func (d *SqliteBackend) SetAllowKeyless(allow bool) error {
15 	return wrapDbErr(
16 		wrapTx(d.db, context.Background(), func(tx *sqlx.Tx) error {
17-			_, err := tx.Exec("UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = ?;", "allow_keyless", strconv.FormatBool(allow))
18+			_, err := tx.Exec("UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = ?;", allow, "allow_keyless")
19 			return err
20 		}),
21 	)
22@@ -113,7 +112,7 @@ func (d *SqliteBackend) SetAllowKeyless(allow bool) error {
23 func (d *SqliteBackend) SetAnonAccess(level backend.AccessLevel) error {
24 	return wrapDbErr(
25 		wrapTx(d.db, context.Background(), func(tx *sqlx.Tx) error {
26-			_, err := tx.Exec("UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = ?;", "anon_access", level.String())
27+			_, err := tx.Exec("UPDATE settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE key = ?;", level.String(), "anon_access")
28 			return err
29 		}),
30 	)
31@@ -169,6 +168,7 @@ func (d *SqliteBackend) ImportRepository(name string, remote string, opts backen
32 	repo := name + ".git"
33 	rp := filepath.Join(d.reposPath(), repo)
34 
35+	// TODO: use HTTP(s) or GIT clones
36 	copts := git.CloneOptions{
37 		Mirror: opts.Mirror,
38 		Quiet:  true,
39@@ -176,14 +176,15 @@ func (d *SqliteBackend) ImportRepository(name string, remote string, opts backen
40 			Envs: []string{
41 				fmt.Sprintf(`GIT_SSH_COMMAND=ssh -o UserKnownHostsFile="%s" -o StrictHostKeyChecking=no -i "%s"`,
42 					filepath.Join(d.cfg.DataPath, "ssh", "known_hosts"),
43-					filepath.Join(d.cfg.DataPath, d.cfg.SSH.ClientKeyPath),
44+					// FIXME: upstream keygen appends _ed25519 to the key path.
45+					filepath.Join(d.cfg.DataPath, d.cfg.SSH.ClientKeyPath)+"_ed25519",
46 				),
47 			},
48 		},
49 	}
50 
51 	if err := git.Clone(remote, rp, copts); err != nil {
52-		logger.Debug("failed to clone repository", "err", err, "mirror", opts.Mirror, "remote", remote, "path", rp)
53+		logger.Error("failed to clone repository", "err", err, "mirror", opts.Mirror, "remote", remote, "path", rp)
54 		return nil, err
55 	}
56