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) } } }