You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
459 B
23 lines
459 B
package main
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
var neverExpire = time.Unix(0, 0)
|
|
|
|
// 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)
|
|
}
|
|
|
|
// 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
|
|
}
|