pkg/index: redo indexing of a blob when CAMLI_REDO_INDEX_ON_RECEIVE is set

So an upcoming HEIC reindexing tool.

Updates #969

Change-Id: If194904d770bb670fa581c4e5e09c303806bc784
This commit is contained in:
Brad Fitzpatrick 2018-04-20 19:40:11 -07:00
parent 6af54cc882
commit 61de9881da
2 changed files with 17 additions and 3 deletions

View File

@ -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.

View File

@ -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
}
}
}