2015-09-28 04:17:12 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2015-10-07 07:15:45 +02:00
|
|
|
var neverExpire = time.Unix(0, 0)
|
|
|
|
|
2015-09-28 04:17:12 +02:00
|
|
|
// Determine if a file with expiry set to "ts" has expired yet
|
2015-10-06 08:50:20 +02:00
|
|
|
func isTsExpired(ts time.Time) bool {
|
|
|
|
now := time.Now()
|
2015-10-07 07:15:45 +02:00
|
|
|
return ts != neverExpire && now.After(ts)
|
2015-09-28 04:17:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Determine if the given filename is expired
|
2015-10-08 04:45:34 +02:00
|
|
|
func isFileExpired(filename string) (bool, error) {
|
|
|
|
metadata, err := metadataRead(filename)
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return isTsExpired(metadata.Expiry), nil
|
2015-09-28 04:17:12 +02:00
|
|
|
}
|