func (bm *WriteManager) RecoverIndexFromPackBlob(ctx context.Context, packFile blob.ID, packFileLength int64, commit bool) ([]Info, error) {
	var localIndexBytes gather.WriteBuffer
	defer localIndexBytes.Close()

	if err := bm.readPackFileLocalIndex(ctx, packFile, packFileLength, &localIndexBytes); err != nil {
		return nil, err
	}

	ndx, err := index.Open(localIndexBytes.Bytes().ToByteSlice(), nil, uint32(bm.crypter.Encryptor.Overhead()))
	if err != nil {
		return nil, errors.Errorf("unable to open index in file %v", packFile)
	}

	var recovered []Info

	err = ndx.Iterate(index.AllIDs, func(i Info) error {
		// 'i' is ephemeral and will depend on temporary buffers which
		// won't be available when this function returns, we need to
		// convert it to durable struct.
		is := index.ToInfoStruct(i)

		recovered = append(recovered, is)

		return nil
	})

	if commit {
		bm.lock()
		defer bm.unlock()

		for _, is := range recovered {
			bm.packIndexBuilder.Add(is)
		}
	}

	return recovered, errors.Wrap(err, "error iterating index entries")
}
// RecoverIndexFromPackBlob attempts to recover index blob entries from a given pack file.
// Pack file length may be provided (if known) to reduce the number of bytes that are read from the storage.
RecoverIndexFromPackBlob attempts to recover index blob entries from a given pack file.
Pack file length may be provided (if known) to reduce the number of bytes that are read from the storage.
// RecoverIndexFromPackBlob attempts to recover index blob entries from a given pack file . // Pack file length may be provided ( if known ) to reduce the number of bytes that are read from the storage .
func (bm *WriteManager) RecoverIndexFromPackBlob(ctx context.Context, packFile blob.ID, packFileLength int64, commit bool) ([]Info, error) {
	var localIndexBytes gather.WriteBuffer
	defer localIndexBytes.Close()
	if err := bm.readPackFileLocalIndex(ctx, packFile, packFileLength, &localIndexBytes); err != nil {
		return nil, err
	}
	ndx, err := index.Open(localIndexBytes.Bytes().ToByteSlice(), nil, uint32(bm.crypter.Encryptor.Overhead()))
	if err != nil {
		return nil, errors.Errorf("unable to open index in file %v", packFile)
	}
	var recovered []Info
	err = ndx.Iterate(index.AllIDs, func(i Info) error {
		is := index.ToInfoStruct(i)
		recovered = append(recovered, is)
		return nil
	})
	if commit {
		bm.lock()
		defer bm.unlock()
		for _, is := range recovered {
			bm.packIndexBuilder.Add(is)
		}
	}
	return recovered, errors.Wrap(err, "error iterating index entries")
}
func ( bm * WriteManager ) RecoverIndexFromPackBlob ( ctx context . Context , packFile blob . ID , packFileLength int64 , commit bool ) ( [ ] Info , error ) { var localIndexBytes gather . WriteBuffer defer localIndexBytes . Close ( ) if err := bm . readPackFileLocalIndex ( ctx , packFile , packFileLength , & localIndexBytes ) ; err != nil { return nil , err } ndx , err := index . Open ( localIndexBytes . Bytes ( ) . ToByteSlice ( ) , nil , uint32 ( bm . crypter . Encryptor . Overhead ( ) ) ) if err != nil { return nil , errors . Errorf ( " " , packFile ) } var recovered [ ] Info err = ndx . Iterate ( index . AllIDs , func ( i Info ) error { is := index . ToInfoStruct ( i ) recovered = append ( recovered , is ) return nil } ) if commit { bm . lock ( ) defer bm . unlock ( ) for _ , is := range recovered { bm . packIndexBuilder . Add ( is ) } } return recovered , errors . Wrap ( err , " " ) }
RecoverIndexFromPackBlob attempts to recover index blob entries from a given pack file.
RecoverIndexFromPackBlob attempts to recover index blob entries from a given pack file .
// 'i' is ephemeral and will depend on temporary buffers which // won't be available when this function returns, we need to // convert it to durable struct.