MCPcopy
hub / github.com/benbjohnson/litestream / waitForRestorePlan

Method waitForRestorePlan

vfs.go:2733–2761  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2731}
2732
2733func (f *VFSFile) waitForRestorePlan() ([]*ltx.FileInfo, error) {
2734 // If write mode is enabled, don't wait - return immediately so we can
2735 // create a new database if no files exist.
2736 if f.writeEnabled {
2737 infos, err := CalcRestorePlan(f.ctx, f.client, 0, time.Time{}, f.logger)
2738 if err != nil {
2739 return nil, err
2740 }
2741 return infos, nil
2742 }
2743
2744 // For read-only mode, wait for files to become available
2745 for {
2746 infos, err := CalcRestorePlan(f.ctx, f.client, 0, time.Time{}, f.logger)
2747 if err == nil {
2748 return infos, nil
2749 }
2750 if !errors.Is(err, ErrTxNotAvailable) {
2751 return nil, fmt.Errorf("cannot calc restore plan: %w", err)
2752 }
2753
2754 f.logger.Debug("no backup files available yet, waiting", "interval", f.PollInterval)
2755 select {
2756 case <-time.After(f.PollInterval):
2757 case <-f.ctx.Done():
2758 return nil, fmt.Errorf("no backup files available: %w", f.ctx.Err())
2759 }
2760 }
2761}
2762
2763// RegisterVFSConnection maps a SQLite connection handle to its VFS file ID.
2764func RegisterVFSConnection(dbPtr uintptr, fileID uint64) error {

Callers 1

OpenMethod · 0.95

Calls 3

CalcRestorePlanFunction · 0.85
IsMethod · 0.80
ErrMethod · 0.45

Tested by

no test coverage detected