From 3e18b6cc3dec8597d4762bc7311ba5ce95710a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ri=C3=9Fe?= Date: Wed, 23 Aug 2023 13:53:28 +0200 Subject: [PATCH] git-annex: do not block database in doArchive This commit can be dropped as soon as https://github.com/go-gitea/gitea/pull/27563 is accepted. --- services/repository/archiver/archiver.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/services/repository/archiver/archiver.go b/services/repository/archiver/archiver.go index bbeefd7fd953..053c52d9771d 100644 --- a/services/repository/archiver/archiver.go +++ b/services/repository/archiver/archiver.go @@ -278,6 +278,13 @@ func doArchive(ctx context.Context, r *ArchiveRequest) (*repo_model.RepoArchiver // TODO: add lfs data to zip // TODO: add submodule data to zip + // commit and close here to avoid blocking the database for the entirety of the archive generation process (might only be an issue with sqlite) + err = committer.Commit() + if err != nil { + return nil, err + } + committer.Close() + if _, err := storage.RepoArchives.Save(rPath, rd, -1); err != nil { return nil, fmt.Errorf("unable to write archive: %w", err) } @@ -287,6 +294,14 @@ func doArchive(ctx context.Context, r *ArchiveRequest) (*repo_model.RepoArchiver return nil, err } + txCtx, committer, err = db.TxContext(db.DefaultContext) + if err != nil { + return nil, err + } + defer committer.Close() + ctx, _, finished = process.GetManager().AddContext(txCtx, fmt.Sprintf("ArchiveRequest[%d]: %s", r.RepoID, r.GetArchiveName())) + defer finished() + if archiver.Status == repo_model.ArchiverGenerating { archiver.Status = repo_model.ArchiverReady if err = repo_model.UpdateRepoArchiverStatus(ctx, archiver); err != nil {