Example #1
0
func (a *archiver) push(item *archiverItem) Future {
	if a.pushLocked(item) {
		tracer.Instant(a, "itemAdded", tracer.Thread, tracer.Args{"item": item.DisplayName()})
		tracer.CounterAdd(a, "itemsAdded", 1)
		a.progress.Update(groupFound, groupFoundFound, 1)
		return item
	}
	item.Close()
	return nil
}
Example #2
0
// Close waits for all pending files to be done.
func (a *archiver) Close() error {
	// This is done so asynchronously calling push() won't crash.

	a.closeLock.Lock()
	ok := false
	if a.stage1DedupeChan != nil {
		close(a.stage1DedupeChan)
		a.stage1DedupeChan = nil
		ok = true
	}
	a.closeLock.Unlock()

	if !ok {
		return errors.New("was already closed")
	}
	a.wg.Wait()
	_ = a.progress.Close()
	_ = a.canceler.Close()
	err := a.CancelationReason()
	tracer.Instant(a, "done", tracer.Global, nil)
	return err
}
Example #3
0
func (a *archiver) Cancel(reason error) {
	tracer.Instant(a, "cancel", tracer.Thread, tracer.Args{"reason": reason})
	a.canceler.Cancel(reason)
}