From 7fd34048abb5cfadae75e4162ea9f50848133d9f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 5 Jul 2018 17:06:50 -0700 Subject: [PATCH] explain when a promise can be canceled in pbdagreader License: MIT Signed-off-by: Steven Allen --- unixfs/io/pbdagreader.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unixfs/io/pbdagreader.go b/unixfs/io/pbdagreader.go index 9c3909577..42d903aac 100644 --- a/unixfs/io/pbdagreader.go +++ b/unixfs/io/pbdagreader.go @@ -110,6 +110,11 @@ func (dr *PBDagReader) precalcNextBuf(ctx context.Context) error { // In this case, the context used to *preload* the node has been canceled. // We need to retry the load with our context and we might as // well preload some extra nodes while we're at it. + // + // Note: When using `Read`, this code will never execute as + // `Read` will use the global context. It only runs if the user + // explicitly reads with a custom context (e.g., by calling + // `CtxReadFull`). dr.preload(ctx, dr.linkPosition) nxt, err = dr.promises[dr.linkPosition].Get(ctx) dr.promises[dr.linkPosition] = nil