Remove memdb for gist init (#421)

This commit is contained in:
Thomas Miceli
2025-01-30 10:46:35 +01:00
committed by GitHub
parent 62d56cd1c7
commit 76fc129c09
8 changed files with 80 additions and 101 deletions

View File

@ -23,7 +23,6 @@ import (
"github.com/thomiceli/opengist/internal/auth"
"github.com/thomiceli/opengist/internal/db"
"github.com/thomiceli/opengist/internal/git"
"github.com/thomiceli/opengist/internal/memdb"
"gorm.io/gorm"
)
@ -157,18 +156,18 @@ func GitHttp(ctx *context.Context) error {
return ctx.ErrorRes(500, "Cannot init repository in database", err)
}
if err := memdb.InsertGistInit(user.ID, gist); err != nil {
return ctx.ErrorRes(500, "Cannot save the URL for the new Gist", err)
err = gist.SerialiseInitRepository()
if err != nil {
return ctx.ErrorRes(500, "Cannot serialise the repository", err)
}
ctx.SetData("gist", gist)
} else {
gistFromMemdb, err := memdb.GetGistInitAndDelete(user.ID)
gist, err = db.DeserialiseInitRepository(user.Username)
if err != nil {
return ctx.ErrorRes(500, "Cannot get the gist link from the in memory database", err)
return ctx.ErrorRes(500, "Cannot deserialise the repository", err)
}
gist := gistFromMemdb.Gist
ctx.SetData("gist", gist)
ctx.SetData("repositoryPath", git.RepositoryPath(gist.User.Username, gist.Uuid))
}

View File

@ -21,7 +21,6 @@ import (
"github.com/thomiceli/opengist/internal/config"
"github.com/thomiceli/opengist/internal/db"
"github.com/thomiceli/opengist/internal/git"
"github.com/thomiceli/opengist/internal/memdb"
"github.com/thomiceli/opengist/internal/web/server"
)
@ -183,9 +182,6 @@ func Setup(t *testing.T) *TestServer {
log.Fatal().Err(err).Msg("Could not initialize database")
}
err = memdb.Setup()
require.NoError(t, err, "Could not initialize in memory database")
// err = index.Open(filepath.Join(homePath, "testsindex", "opengist.index"))
// require.NoError(t, err, "Could not open index")