예제 #1
0
파일: index.go 프로젝트: koding/koding
// ctime gets file's change time in UNIX Nano format.
func ctime(fi os.FileInfo) int64 {
	if tspec := times.Get(fi); tspec.HasChangeTime() {
		return tspec.ChangeTime().UnixNano()
	}

	return 0
}
예제 #2
0
// Clean (remove) files in `md+"/tmp/"` not accessed in the last 36
// hours.
func (md Maildir) Clean() error {
	dir, err := os.Open(string(md) + "/tmp")
	if err != nil {
		return err
	}
	fileinfos, err := dir.Readdir(0)
	if err != nil {
		return err
	}
	for _, fileinfo := range fileinfos {
		if strings.HasPrefix(fileinfo.Name(), ".") {
			continue
		}
		atime := times.Get(fileinfo).AccessTime()
		if time.Since(atime) > (36 * time.Hour) {
			path := string(md) + "/tmp/" + fileinfo.Name()
			err1 := syscall.Unlink(path)
			if err1 != nil {
				err = &os.PathError{Op: "unlink", Path: path, Err: err1}
			}
		}
	}
	return err
}