@@ -2296,8 +2296,8 @@ func (c *Catalog) GetRange(ctx context.Context, repositoryID, rangeID string) (g
2296
2296
return c .Store .GetRange (ctx , repository , graveler .RangeID (rangeID ))
2297
2297
}
2298
2298
2299
- func (c * Catalog ) importAsync (repository * graveler.RepositoryRecord , branchID , importID string , params ImportRequest , logger logging.Logger ) error {
2300
- ctx , cancel := context .WithCancel (context . Background ()) // Need a new context for the async operations
2299
+ func (c * Catalog ) importAsync (ctx context. Context , repository * graveler.RepositoryRecord , branchID , importID string , params ImportRequest , logger logging.Logger ) error {
2300
+ ctx , cancel := context .WithCancel (ctx )
2301
2301
defer cancel ()
2302
2302
2303
2303
importManager , err := NewImport (ctx , cancel , logger , c .KVStore , repository , importID )
@@ -2419,7 +2419,9 @@ func (c *Catalog) Import(ctx context.Context, repositoryID, branchID string, par
2419
2419
// Run import
2420
2420
go func () {
2421
2421
logger := c .log (ctx ).WithField ("import_id" , id )
2422
- err = c .importAsync (repository , branchID , id , params , logger )
2422
+ // Passing context.WithoutCancel to avoid canceling the import operation when the wrapping Import function returns,
2423
+ // and keep the context's fields intact for next operations (for example, PreCommitHook runs).
2424
+ err = c .importAsync (context .WithoutCancel (ctx ), repository , branchID , id , params , logger )
2423
2425
if err != nil {
2424
2426
logger .WithError (err ).Error ("import failure" )
2425
2427
}
0 commit comments