diff --git a/doc/environment-vars.md b/doc/environment-vars.md index ead148a41..ccc0bb577 100644 --- a/doc/environment-vars.md +++ b/doc/environment-vars.md @@ -222,6 +222,12 @@ files to be ignored by [pkg/client](/pkg/client) when uploading. : If true, no thumbnail caching is done, and URLs even have cache buster components, to force browsers to reload a lot. +`CAMLI_REDO_INDEX_ON_RECEIVE` (bool) +: If true, the indexer will always index any blob it receives, regardless of + whether it thinks it's done it in the past. This is generally only useful when + working on the indexing code and retroactively indexing a subset of content + without forcing a global reindexing. + `CAMLI_VAR_DIR` (string) : Path used by [pkg/osutil](/pkg/osutil) to override operating system specific application storage directory. Generally unused. diff --git a/pkg/index/receive.go b/pkg/index/receive.go index d73e39365..e982352df 100644 --- a/pkg/index/receive.go +++ b/pkg/index/receive.go @@ -220,9 +220,17 @@ func (ix *Index) ReceiveBlob(ctx context.Context, blobRef blob.Ref, source io.Re } }() - if haveVal, haveErr := ix.s.Get("have:" + blobRef.String()); haveErr == nil { - if strings.HasSuffix(haveVal, "|indexed") { - return sbr, nil + // By default, return immediately if it looks like we already + // have indexed this blob before. But if the user has + // CAMLI_REDO_INDEX_ON_RECEIVE set in their environment, + // always index it. This is generally only useful when working + // on the indexing code and retroactively indexing a subset of + // content without forcing a global reindexing. + if allowReindex, _ := strconv.ParseBool(os.Getenv("CAMLI_REDO_INDEX_ON_RECEIVE")); !allowReindex { + if haveVal, haveErr := ix.s.Get("have:" + blobRef.String()); haveErr == nil { + if strings.HasSuffix(haveVal, "|indexed") { + return sbr, nil + } } }