MCPcopy
hub / github.com/syncthing/syncthing / Completion

Method Completion

lib/model/model.go:883–912  ·  view source on GitHub ↗

Completion returns the completion status, in percent with some counters, for the given device and folder. The device can be any known device ID (including the local device) or explicitly protocol.LocalDeviceID. An empty folder string means the aggregate of all folders shared with the given device.

(device protocol.DeviceID, folder string)

Source from the content-addressed store, hash-verified

881// empty folder string means the aggregate of all folders shared with the
882// given device.
883func (m *model) Completion(device protocol.DeviceID, folder string) (FolderCompletion, error) {
884 // The user specifically asked for our own device ID. Internally that is
885 // known as protocol.LocalDeviceID so translate.
886 if device == m.id {
887 device = protocol.LocalDeviceID
888 }
889
890 if folder != "" {
891 // We want completion for a specific folder.
892 return m.folderCompletion(device, folder)
893 }
894
895 // We want completion for all (shared) folders as an aggregate.
896 var comp FolderCompletion
897 for _, fcfg := range m.cfg.FolderList() {
898 if fcfg.Paused {
899 continue
900 }
901 if device == protocol.LocalDeviceID || fcfg.SharedWith(device) {
902 folderComp, err := m.folderCompletion(device, fcfg.ID)
903 if errors.Is(err, ErrFolderPaused) {
904 continue
905 } else if err != nil {
906 return FolderCompletion{}, err
907 }
908 comp.add(folderComp)
909 }
910 }
911 return comp, nil
912}
913
914func (m *model) folderCompletion(device protocol.DeviceID, folder string) (FolderCompletion, error) {
915 m.mut.RLock()

Callers

nothing calls this directly

Calls 5

folderCompletionMethod · 0.95
addMethod · 0.95
SharedWithMethod · 0.80
FolderListMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected