Пример #1
0
func main() {
	ch := make(chan changes.Change)

	for _, watch := range os.Args[1:] {
		go changes.Watch(watch, ch)
	}

	for c := range ch {
		fmt.Printf("%s|%s|%s\n", c.Operation, c.Base, c.Path)
	}
}
Пример #2
0
func (s *Sync) watchOutgoing(st Stream) {
	ch := make(chan changes.Change)

	go changes.Watch(s.Local, ch)

	for c := range ch {
		s.lock.Lock()

		if s.outgoingBlocks[c.Path] > 0 {
			s.outgoingBlocks[c.Path] -= 1
		} else {
			s.outgoing[c] = true
		}

		s.lock.Unlock()
	}
}
Пример #3
0
func (s *Sync) watchOutgoing(st Stream) {
	ch := make(chan changes.Change, 1)

	go func() {
		if err := changes.Watch(s.Local, ch); err != nil {
			st <- fmt.Sprintf("error: %s", err)
		}
	}()

	for c := range ch {
		s.lock.Lock()

		if s.outgoingBlocks[c.Path] > 0 {
			s.outgoingBlocks[c.Path] -= 1
		} else {
			s.outgoing <- c
		}

		s.lock.Unlock()
	}
}