func (suite *DynamicObjPropStoreSuite) createProvider(filler func(consumer objprop.Consumer)) objprop.Provider { store := serial.NewByteStore() consumer := dos.NewConsumer(store, suite.descriptors) filler(consumer) consumer.Finish() provider, _ := dos.NewProvider(bytes.NewReader(store.Data()), suite.descriptors) return provider }
func (library *ReleaseStoreLibrary) saveAndReloadObjpropData(data []byte, path string, name string) (provider objprop.Provider, reader serial.SeekingReadCloser) { newResource, err := library.saveResource(data, path, name) if err == nil { reader, err = newResource.AsSource() } if err == nil { provider, err = dosObjprop.NewProvider(reader, library.descriptors) 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, _ = dosObjprop.NewProvider(reader, library.descriptors) } return }
func (library *ReleaseStoreLibrary) openObjpropStoreFrom(rel release.Release, name string) (objpropStore objprop.Store, err error) { resource, err := rel.GetResource(name) if err == nil { var reader serial.SeekingReadCloser reader, err = resource.AsSource() if err == nil { var provider objprop.Provider provider, err = dosObjprop.NewProvider(reader, library.descriptors) if err == nil { objpropStore = library.createSavingObjpropStore(provider, resource.Path(), name, func() { reader.Close() }) } } } return }