MCPcopy
hub / github.com/syncthing/syncthing / newSharedPullerState

Function newSharedPullerState

lib/model/sharedpullerstate.go:57–84  ·  view source on GitHub ↗
(file protocol.FileInfo, fs fs.Filesystem, folderID, tempName string, blocks []protocol.BlockInfo, reused []int, ignorePerms, hasCurFile bool, curFile protocol.FileInfo, sparse bool, fsync bool)

Source from the content-addressed store, hash-verified

55}
56
57func newSharedPullerState(file protocol.FileInfo, fs fs.Filesystem, folderID, tempName string, blocks []protocol.BlockInfo, reused []int, ignorePerms, hasCurFile bool, curFile protocol.FileInfo, sparse bool, fsync bool) *sharedPullerState {
58 // Map the existing blocks by hash to block index in the current file
59 blocksMap := make(map[string]int, len(curFile.Blocks))
60 for idx, block := range curFile.Blocks {
61 blocksMap[string(block.Hash)] = idx
62 }
63
64 return &sharedPullerState{
65 file: file,
66 fs: fs,
67 folder: folderID,
68 tempName: tempName,
69 realName: file.Name,
70 copyTotal: len(blocks),
71 copyNeeded: len(blocks),
72 reused: len(reused),
73 updated: time.Now(),
74 available: reused,
75 availableUpdated: time.Now(),
76 ignorePerms: ignorePerms,
77 hasCurFile: hasCurFile,
78 curFile: curFile,
79 curFileBlocks: blocksMap,
80 sparse: sparse,
81 fsync: fsync,
82 created: time.Now(),
83 }
84}
85
86// A momentary state representing the progress of the puller
87type PullerProgress struct {

Callers 3

TestPullCtxCancelFunction · 0.85
TestPullEmptyBlockFunction · 0.85
handleFileMethod · 0.85

Calls 1

NowMethod · 0.65

Tested by 2

TestPullCtxCancelFunction · 0.68
TestPullEmptyBlockFunction · 0.68