MCPcopy
hub / github.com/minio/minio-go / getDataReader

Function getDataReader

functional_tests.go:347–362  ·  view source on GitHub ↗

read data from file if it exists or optionally create a buffer of particular size

(fileName string)

Source from the content-addressed store, hash-verified

345
346// read data from file if it exists or optionally create a buffer of particular size
347func getDataReader(fileName string) io.ReadCloser {
348 if mintDataDir == "" {
349 size := int64(dataFileMap[fileName])
350 if _, ok := dataFileCRC32[fileName]; !ok {
351 dataFileCRC32[fileName] = mustCrcReader(newRandomReader(size, size))
352 }
353 return io.NopCloser(newRandomReader(size, size))
354 }
355 reader, _ := os.Open(getMintDataDirFilePath(fileName))
356 if _, ok := dataFileCRC32[fileName]; !ok {
357 dataFileCRC32[fileName] = mustCrcReader(reader)
358 reader.Close()
359 reader, _ = os.Open(getMintDataDirFilePath(fileName))
360 }
361 return reader
362}
363
364// randString generates random names and prepends them with a known prefix.
365func randString(n int, src rand.Source, prefix string) string {

Calls 4

mustCrcReaderFunction · 0.85
newRandomReaderFunction · 0.85
getMintDataDirFilePathFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected