mirror of https://github.com/perkeep/perkeep.git
index: re-index on file failure. Issue 103.
Change-Id: I740dbcf951d865df32c2f54d9d4119af135713db
This commit is contained in:
parent
f8639c5c5c
commit
51d79e8759
|
@ -545,6 +545,7 @@ func (x *Index) GetFileInfo(fileRef *blobref.BlobRef) (*search.FileInfo, error)
|
|||
key := "fileinfo|" + fileRef.String()
|
||||
v, err := x.s.Get(key)
|
||||
if err == ErrNotFound {
|
||||
go x.reindex(fileRef) // kinda a hack. Issue 103.
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
valPart := strings.Split(v, "|")
|
||||
|
|
|
@ -42,6 +42,27 @@ func (ix *Index) GetBlobHub() blobserver.BlobHub {
|
|||
return ix.SimpleBlobHubPartitionMap.GetBlobHub()
|
||||
}
|
||||
|
||||
func (ix *Index) reindex(br *blobref.BlobRef) {
|
||||
bs := ix.BlobSource
|
||||
if bs == nil {
|
||||
log.Printf("index: can't re-index %v: no BlobSource", br)
|
||||
return
|
||||
}
|
||||
log.Printf("index: starting re-index of %v", br)
|
||||
rc, _, err := bs.FetchStreaming(br)
|
||||
if err != nil {
|
||||
log.Printf("index: failed to fetch %v for reindexing: %v", br, err)
|
||||
return
|
||||
}
|
||||
defer rc.Close()
|
||||
sb, err := ix.ReceiveBlob(br, rc)
|
||||
if err != nil {
|
||||
log.Printf("index: reindex of %v failed: %v", br, err)
|
||||
return
|
||||
}
|
||||
log.Printf("index: successfully reindexed %v", sb)
|
||||
}
|
||||
|
||||
func (ix *Index) ReceiveBlob(blobRef *blobref.BlobRef, source io.Reader) (retsb blobref.SizedBlobRef, err error) {
|
||||
sniffer := NewBlobSniffer(blobRef)
|
||||
hash := blobRef.Hash()
|
||||
|
|
Loading…
Reference in New Issue