MCPcopy
hub / github.com/perkeep/perkeep / openAllPacks

Method openAllPacks

pkg/blobserver/diskpacked/diskpacked.go:311–332  ·  view source on GitHub ↗

openAllPacks opens read-only each pack file in s.root, populating s.fds. The latest pack file will also have a writable handle opened. This function is not thread safe, s.mu should be locked by the caller.

()

Source from the content-addressed store, hash-verified

309// The latest pack file will also have a writable handle opened.
310// This function is not thread safe, s.mu should be locked by the caller.
311func (s *storage) openAllPacks() error {
312 debug.Println("diskpacked: openAllPacks")
313 n := 0
314 for {
315 err := s.openForRead(n)
316 if os.IsNotExist(err) {
317 break
318 }
319 if err != nil {
320 return err
321 }
322 n++
323 }
324
325 if n == 0 {
326 // If no pack files are found, we create one open for read and write.
327 return s.nextPack()
328 }
329
330 // If 1 or more pack files are found, open the last one read and write.
331 return s.openForWrite(n - 1)
332}
333
334// Close index and all opened fds, with locking.
335func (s *storage) Close() error {

Callers 1

newStorageFunction · 0.80

Calls 4

openForReadMethod · 0.95
nextPackMethod · 0.95
openForWriteMethod · 0.95
PrintlnMethod · 0.80

Tested by

no test coverage detected