mirror of
https://github.com/logos-storage/logos-storage-go-bindings.git
synced 2026-01-02 13:33:10 +00:00
Defer channel close
This commit is contained in:
parent
bc8bbf4172
commit
a9fd02863c
@ -210,7 +210,11 @@ func (node CodexNode) DownloadStream(ctx context.Context, cid string, options Do
|
||||
return bridge.callError("cGoCodexDownloadLocal")
|
||||
}
|
||||
|
||||
// Create a done channel to signal the goroutine to stop
|
||||
// when the download is complete and avoid goroutine leaks.
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
|
||||
channelError := make(chan error, 1)
|
||||
go func() {
|
||||
select {
|
||||
@ -222,7 +226,6 @@ func (node CodexNode) DownloadStream(ctx context.Context, cid string, options Do
|
||||
}()
|
||||
|
||||
_, err = bridge.wait()
|
||||
close(done)
|
||||
|
||||
// Extract the potential cancellation error
|
||||
var cancelError error
|
||||
|
||||
@ -305,7 +305,11 @@ func (node CodexNode) UploadFile(ctx context.Context, options UploadOptions) (st
|
||||
return "", bridge.callError("cGoCodexUploadFile")
|
||||
}
|
||||
|
||||
// Create a done channel to signal the goroutine to stop
|
||||
// when the download is complete and avoid goroutine leaks.
|
||||
done := make(chan struct{})
|
||||
defer close(done)
|
||||
|
||||
channelError := make(chan error, 1)
|
||||
go func() {
|
||||
select {
|
||||
@ -317,7 +321,6 @@ func (node CodexNode) UploadFile(ctx context.Context, options UploadOptions) (st
|
||||
}()
|
||||
|
||||
_, err = bridge.wait()
|
||||
close(done)
|
||||
|
||||
// Extract the potential cancellation error
|
||||
var cancelErr error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user