Skip to content

Commit

Permalink
git-annex: do not block database in doArchive
Browse files Browse the repository at this point in the history
This commit can be dropped as soon as
go-gitea#27563 is accepted.
  • Loading branch information
matrss authored and kousu committed Nov 4, 2023
1 parent 1935edb commit a1d75f5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions services/repository/archiver/archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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 {
Expand Down

0 comments on commit a1d75f5

Please sign in to comment.