OlderThan returns the list of cache directories older than max.
(basedir string, max time.Duration)
| 205 | |
| 206 | // OlderThan returns the list of cache directories older than max. |
| 207 | func OlderThan(basedir string, max time.Duration) ([]os.FileInfo, error) { |
| 208 | entries, err := listCacheDirs(basedir) |
| 209 | if err != nil { |
| 210 | return nil, err |
| 211 | } |
| 212 | |
| 213 | var oldCacheDirs []os.FileInfo |
| 214 | for _, fi := range entries { |
| 215 | if !IsOld(fi.ModTime(), max) { |
| 216 | continue |
| 217 | } |
| 218 | |
| 219 | oldCacheDirs = append(oldCacheDirs, fi) |
| 220 | } |
| 221 | |
| 222 | debug.Log("%d old cache dirs found", len(oldCacheDirs)) |
| 223 | |
| 224 | return oldCacheDirs, nil |
| 225 | } |
| 226 | |
| 227 | // Old returns a list of cache directories with a modification time of more |
| 228 | // than 30 days ago. |