Skip to content

Commit a1d75f5

Browse files
matrsskousu
authored andcommitted
git-annex: do not block database in doArchive
This commit can be dropped as soon as go-gitea#27563 is accepted.
1 parent 1935edb commit a1d75f5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

services/repository/archiver/archiver.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,13 @@ func doArchive(ctx context.Context, r *ArchiveRequest) (*repo_model.RepoArchiver
278278
// TODO: add lfs data to zip
279279
// TODO: add submodule data to zip
280280

281+
// commit and close here to avoid blocking the database for the entirety of the archive generation process (might only be an issue with sqlite)
282+
err = committer.Commit()
283+
if err != nil {
284+
return nil, err
285+
}
286+
committer.Close()
287+
281288
if _, err := storage.RepoArchives.Save(rPath, rd, -1); err != nil {
282289
return nil, fmt.Errorf("unable to write archive: %w", err)
283290
}
@@ -287,6 +294,14 @@ func doArchive(ctx context.Context, r *ArchiveRequest) (*repo_model.RepoArchiver
287294
return nil, err
288295
}
289296

297+
txCtx, committer, err = db.TxContext(db.DefaultContext)
298+
if err != nil {
299+
return nil, err
300+
}
301+
defer committer.Close()
302+
ctx, _, finished = process.GetManager().AddContext(txCtx, fmt.Sprintf("ArchiveRequest[%d]: %s", r.RepoID, r.GetArchiveName()))
303+
defer finished()
304+
290305
if archiver.Status == repo_model.ArchiverGenerating {
291306
archiver.Status = repo_model.ArchiverReady
292307
if err = repo_model.UpdateRepoArchiverStatus(ctx, archiver); err != nil {

0 commit comments

Comments
 (0)