~edwargix/git.sr.ht

115487d546787a8321229a142d8af053753696c2 — Adnan Maolood 2 years ago 902c41a
api/graph: Execute webhook queries before deletion

Execute GraphQL webhook queries after the repository has been deleted
from the database, but before the files have been removed from the
filesystem. This prevents filesystem errors during query execution.

We don't need to execute the query before the repository is deleted from
the database since all the information we need from the database has
been retrieved.

References: https://todo.sr.ht/~sircmpwn/sr.ht/301
1 files changed, 3 insertions(+), 3 deletions(-)

M api/graph/schema.resolvers.go
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +3 -3
@@ 453,13 453,13 @@ func (r *mutationResolver) DeleteRepository(ctx context.Context, id int) (*model
			return err
		}

		webhooks.DeliverRepoEvent(ctx, model.WebhookEventRepoDeleted, &repo)
		webhooks.DeliverLegacyRepoDeleted(ctx, &repo)

		err := os.RemoveAll(repo.Path)
		if err != nil {
			return err
		}

		webhooks.DeliverRepoEvent(ctx, model.WebhookEventRepoDeleted, &repo)
		webhooks.DeliverLegacyRepoDeleted(ctx, &repo)
		return nil
	}); err != nil {
		return nil, err