func (env *Env) Write() { util.RemoveDir(env.dir) util.PrepareDir(env.dir) util.PrepareDir(getZenvPath()) util.PrepareDir(getEnvsPath()) env.writeInfo() env.items.Write(env.dir) if !env.global { env.addEnvDir() } }
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)) } } }
func ClearTemporal() { now := time.Now() for _, dir := range util.GetAllDir(GetStoragePath(TMP)) { last := util.ReadFile(getStorageFilePath(TMP, dir, LAST)) if len(last) != 1 { updateLast(dir) continue } ti, err := time.Parse(time.ANSIC, last[0]) if err == nil { if int(now.Sub(ti).Hours())/24 > remove { util.RemoveDir(GetStorageDir(TMP, dir)) } } else { updateLast(dir) } } }
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)) } }
func initializeLink(dir string) { pa := GetVBinPath(dir) util.RemoveDir(pa) util.PrepareDir(pa) }