Пример #1
0
func (tgt *TargetDir) Chasing(mode int) (err error) {

	//fmt.Printf("Chasing:dir")

	actual_prop := actuator.GetProp(tgt.Path, mode)

	if actual_prop.Error == true { /*fmt.Printf("\nError during opening %s\n",tgt.Path)*/
	}

	if tgt.WorkerPool == nil { /*fmt.Printf("%s wp is nil",tgt.Path)*/
	}

	if err != nil {
		return err
	}

	if tgt.Dir != "" {
		select {
		case <-tgt.InfoIn:
			return nil
		default:
		}

		if tgt.InformAboutExit == true {

			var new_items = []string{tgt.Path}
			subdirs := make(map[string]*TargetDir)
			tgt_new := &TargetDir{}
			tgt_new.MessageChannel = tgt.MessageChannel
			tgt_new.Path = tgt.Path
			tgt_new.InfoIn = tgt.InfoIn
			tgt_new.InfoOut = tgt.InfoOut
			tgt_new.Dir = tgt.Dir
			tgt_new.InOutChannelsCreated = true
			tgt_new.WorkerPool = tgt.WorkerPool
			subdirs[tgt.Path] = tgt_new

			// watafa possible mistake cause  was found . it is tgt.InformAboutExit
			tgt.InformAboutExit = false
			// second possible mistake cause
			tgt.Prop = actual_prop

			go Start(new_items, tgt.MessageChannel, tgt.WorkerPool, &subdirs)

			return nil

		}

	} else if tgt.InformAboutExit == true {

		var new_items = []string{tgt.Path}

		subdirs := make(map[string]*TargetDir)
		tgt_new := &TargetDir{}
		tgt_new.MessageChannel = tgt.MessageChannel
		tgt_new.Path = tgt.Path
		tgt_new.InfoIn = tgt.InfoIn
		tgt_new.InfoOut = tgt.InfoOut
		tgt_new.InOutChannelsCreated = true
		tgt_new.WorkerPool = tgt.WorkerPool
		subdirs[tgt.Path] = tgt_new

		// watafa possible mistake was found . it is tgt.InformAboutExit
		tgt.InformAboutExit = false
		// second possible mistake cause
		tgt.Prop = actual_prop

		go Start(new_items, tgt.MessageChannel, tgt.WorkerPool, &subdirs)

		return nil

	}
	if tgt.InitialCheck == true {
		empty_prop := &actuator.Prop{}
		if comparison_notes := actuator.CompareProp(empty_prop, actual_prop, tgt.Path); len(comparison_notes.List) > 0 {
			tgt.MessageChannel <- comparison_notes
		}
		tgt.InitialCheck = false
	}

	//if ( reflect.DeepEqual( actual_prop, tgt.Prop ) == false ) {
	if comparison_notes := actuator.CompareProp(tgt.Prop, actual_prop, tgt.Path); len(comparison_notes.List) > 0 {
		tgt.MessageChannel <- comparison_notes
		tgt.Prop = actual_prop

		for chan_id := range tgt.InfoInArray {
			tgt.InfoInArray[chan_id] <- true
		}

		tgt.InformAboutExit = true

	}
	return nil
}
Пример #2
0
func (tgt *Target) Chasing(mode int) (err error) {

	//fmt.Printf("\nChasing:file")

	//for {

	if tgt.Dir != "" {

		select {

		case <-tgt.InfoIn:
			return nil
		default:

			actual_prop := actuator.GetProp(tgt.Path, mode)
			if actual_prop.Error == true {
				error_field := evebridge.CompNote{Field: "Error", Before: "false", After: "true"}
				cnote := evebridge.CompNotes{Path: tgt.Path}
				cnote.List = append(cnote.List, error_field)
				tgt.MessageChannel <- cnote
				tgt.InformAboutExit = true
				return err
			}
			//if ( reflect.DeepEqual(actual_prop, tgt.Prop) == false ) {
			if tgt.InitialCheck == true {
				empty_prop := &actuator.Prop{}
				if comparison_notes := actuator.CompareProp(empty_prop, actual_prop, tgt.Path); len(comparison_notes.List) > 0 {
					tgt.MessageChannel <- comparison_notes
				}
				tgt.InitialCheck = false
			}

			if comparison_notes := actuator.CompareProp(tgt.Prop, actual_prop, tgt.Path); len(comparison_notes.List) > 0 {
				//go  tgt.Reporting()
				tgt.MessageChannel <- comparison_notes
				tgt.Prop = actual_prop
			}
		}

	} else {
		actual_prop := actuator.GetProp(tgt.Path, mode)

		if actual_prop.Error == true {
			error_field := evebridge.CompNote{Field: "Error", Before: "false", After: "true"}
			cnote := evebridge.CompNotes{Path: tgt.Path}
			cnote.List = append(cnote.List, error_field)
			tgt.MessageChannel <- cnote
			tgt.InformAboutExit = true
			return err

		}
		if tgt.InitialCheck == true {
			empty_prop := &actuator.Prop{}
			if comparison_notes := actuator.CompareProp(empty_prop, actual_prop, tgt.Path); len(comparison_notes.List) > 0 {
				tgt.MessageChannel <- comparison_notes
			}
			tgt.InitialCheck = false
		}

		//if ( reflect.DeepEqual( actual_prop, tgt.Prop ) == false ) {
		if comparison_notes := actuator.CompareProp(tgt.Prop, actual_prop, tgt.Path); len(comparison_notes.List) > 0 {
			//go  tgt.Reporting()
			tgt.MessageChannel <- comparison_notes
			tgt.Prop = actual_prop

		}

	}
	return nil
}