linx-server/expiry.go

24 lines
459 B
Go
Raw Normal View History

2015-09-28 04:17:12 +02:00
package main
import (
"time"
)
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
func isTsExpired(ts time.Time) bool {
now := time.Now()
return ts != neverExpire && now.After(ts)
2015-09-28 04:17:12 +02:00
}
// Determine if the given filename is expired
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
}