carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package hostfiles
2
3import (
4 "context"
5 "os"
6)
7
8// Seed stages the stopped host's wake state and descriptor-opened files tree.
9// The caller owns the descriptor, origin proof and single manifest commit.
10func Seed(ctx context.Context, p *Publisher, root *os.File, wake WakeState, skip func(string, bool) bool) (SyncStats, error) {
11 if ctx == nil || p == nil || root == nil {
12 return SyncStats{}, os.ErrInvalid
13 }
14 if err := ctx.Err(); err != nil {
15 return SyncStats{}, err
16 }
17 if err := StageWake(ctx, p, wake); err != nil {
18 return SyncStats{}, err
19 }
20 stats, err := SyncDirAt(ctx, p, root, skip)
21 if err != nil {
22 return stats, err
23 }
24 if len(stats.Unreadable) != 0 || len(stats.Retry) != 0 || len(stats.Torn) != 0 {
25 return stats, os.ErrInvalid
26 }
27 return stats, nil
28}
29