Example #1
0
func (env *Env) Activate(pid string) {
	storage.ClearTemporal()
	activated := GetActivated(pid)
	if !isActivated(activated, env.name) {
		env.items.Activate(settings.NewInfo(getZenvPath(), env.dir))
		//TODO activate child envs
	}
	//Add to list
	storage.WriteTemporal(pid, ACTIVATED, append(activated, env.name))
}
Example #2
0
func Clean(current string) {
	settings.Initialize(getZenvPath())
	tmpPath := storage.GetStoragePath(storage.TMP)
	for _, dir := range util.GetAllDir(tmpPath) {
		if current != dir {
			activated := util.ReadFile(path.Join(tmpPath, dir, ACTIVATED))
			for _, act := range activated {
				env := getLocalEnv(act)
				if env != nil {
					env.ReadSettings()
					env.items.Clean(settings.NewInfo(getZenvPath(), env.dir))
				}
			}
			util.RemoveDir(path.Join(tmpPath, dir))
		}
	}
}
Example #3
0
func (env *Env) Deactivate(pid string) {
	//Remove from list
	activated := GetActivated(pid)
	for i, actName := range activated {
		if actName == env.name {
			activated = append(activated[:i], activated[i+1:]...)
			break
		}
	}
	storage.WriteTemporal(pid, ACTIVATED, activated)

	if !isActivated(activated, env.name) {
		env.items.Deactivate(settings.NewInfo(getZenvPath(), env.dir))
		//TODO deactivate child envs
	}
	if len(activated) == 0 {
		util.RemoveDir(storage.GetStorageDir(storage.TMP, pid))
	}
}