Exemplo n.º 1
0
// Returns the momentarily progress for the puller
func (s *sharedPullerState) Progress() *pullerProgress {
	s.mut.Lock()
	defer s.mut.Unlock()
	total := s.reused + s.copyTotal + s.pullTotal
	done := total - s.copyNeeded - s.pullNeeded
	return &pullerProgress{
		Total:               total,
		Reused:              s.reused,
		CopiedFromOrigin:    s.copyOrigin,
		CopiedFromElsewhere: s.copyTotal - s.copyNeeded - s.copyOrigin,
		Pulled:              s.pullTotal - s.pullNeeded,
		Pulling:             s.pullNeeded,
		BytesTotal:          db.BlocksToSize(total),
		BytesDone:           db.BlocksToSize(done),
	}
}
Exemplo n.º 2
0
func toNeedSlice(fs []db.FileInfoTruncated) []map[string]interface{} {
	output := make([]map[string]interface{}, len(fs))
	for i, file := range fs {
		output[i] = map[string]interface{}{
			"Name":         file.Name,
			"Flags":        file.Flags,
			"Modified":     file.Modified,
			"Version":      file.Version,
			"LocalVersion": file.LocalVersion,
			"NumBlocks":    file.NumBlocks,
			"Size":         db.BlocksToSize(int(file.NumBlocks)),
		}
	}
	return output
}