MCPcopy Create free account
hub / github.com/couchbase/moss / removeFileOnClose

Method removeFileOnClose

store.go:311–337  ·  view source on GitHub ↗

removeFileOnClose will setup the callback to wipe out the file safely when all references to it are closed.

(fref *FileRef)

Source from the content-addressed store, hash-verified

309// removeFileOnClose will setup the callback to wipe out the file safely
310// when all references to it are closed.
311func (s *Store) removeFileOnClose(fref *FileRef) (os.FileInfo, error) {
312 finfo, err := fref.file.Stat()
313 if err != nil {
314 return nil, err
315 }
316
317 if len(finfo.Name()) > 0 {
318 fref.OnAfterClose(func() {
319 fileName := finfo.Name()
320 go func() {
321 s.m.Lock()
322 delete(s.fileRefMap, fileName)
323 s.m.Unlock()
324 err := os.Remove(path.Join(s.dir, fileName))
325 if err != nil {
326 if s.options.CollectionOptions.Log != nil {
327 s.options.CollectionOptions.Log(
328 "store: error deleting file %s, err: %v",
329 fileName, err)
330 }
331 }
332 }()
333 })
334 }
335
336 return finfo, nil
337}
338
339// --------------------------------------------------------
340

Callers 2

compactMaybeMethod · 0.95
compactMethod · 0.95

Calls 3

StatMethod · 0.80
OnAfterCloseMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected