func (suite *DynamicChunkStoreSuite) createChunkProvider(filler func(consumer chunk.Consumer)) chunk.Provider { store := serial.NewByteStore() consumer := dos.NewChunkConsumer(store) filler(consumer) consumer.Finish() provider, _ := dos.NewChunkProvider(bytes.NewReader(store.Data())) return provider }
func (library *ReleaseStoreLibrary) saveAndReloadChunkData(data []byte, path string, name string) (provider chunk.Provider, reader serial.SeekingReadCloser) { newResource, err := library.saveResource(data, path, name) if err == nil { reader, err = newResource.AsSource() } if err == nil { provider, err = dosChunk.NewChunkProvider(reader) if err != nil { reader.Close() } } if err != nil { log.Printf("Failed to store in sink, buffering: %v\n", err) reader = serial.NewByteStoreFromData(data, func([]byte) {}) provider, _ = dosChunk.NewChunkProvider(reader) } return }
func (library *ReleaseStoreLibrary) openChunkStoreFrom(rel release.Release, name string) (chunkStore chunk.Store, err error) { resource, err := rel.GetResource(name) if err == nil { var reader serial.SeekingReadCloser reader, err = resource.AsSource() if err == nil { var provider chunk.Provider provider, err = dosChunk.NewChunkProvider(reader) if err == nil { chunkStore = library.createSavingChunkStore(provider, resource.Path(), name, func() { reader.Close() }) } } } return }