MCPcopy
hub / github.com/wavetermdev/waveterm / flushToDB

Method flushToDB

pkg/filestore/blockstore_cache.go:329–350  ·  view source on GitHub ↗
(ctx context.Context, replace bool)

Source from the content-addressed store, hash-verified

327}
328
329func (entry *CacheEntry) flushToDB(ctx context.Context, replace bool) error {
330 if entry.File == nil {
331 return nil
332 }
333 err := dbWriteCacheEntry(ctx, entry.File, entry.DataEntries, replace)
334 if ctx.Err() != nil {
335 // transient error
336 return ctx.Err()
337 }
338 if err != nil {
339 flushErrorCount.Add(1)
340 entry.FlushErrors++
341 if entry.FlushErrors > 3 {
342 entry.clear()
343 return fmt.Errorf("too many flush errors (clearing entry): %w", err)
344 }
345 return err
346 }
347 // clear cache entry (data is now in db)
348 entry.clear()
349 return nil
350}

Callers 2

WriteFileMethod · 0.80
FlushCacheMethod · 0.80

Calls 3

clearMethod · 0.95
dbWriteCacheEntryFunction · 0.85
ErrMethod · 0.80

Tested by

no test coverage detected