2015-09-28 04:17:12 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Get what the unix timestamp will be in "seconds".
|
|
|
|
func getFutureTimestamp(seconds int32) (ts int32) {
|
|
|
|
now := int32(time.Now().Unix())
|
|
|
|
|
|
|
|
if seconds == 0 {
|
|
|
|
ts = 0
|
|
|
|
} else {
|
|
|
|
ts = now + seconds
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine if a file with expiry set to "ts" has expired yet
|
|
|
|
func isTsExpired(ts int32) (expired bool) {
|
|
|
|
now := int32(time.Now().Unix())
|
|
|
|
|
|
|
|
if ts == 0 {
|
|
|
|
expired = false
|
|
|
|
} else if now > ts {
|
|
|
|
expired = true
|
|
|
|
} else {
|
|
|
|
expired = false
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine if the given filename is expired
|
2015-09-28 06:25:57 +02:00
|
|
|
func isFileExpired(filename string) bool {
|
|
|
|
exp, _ := metadataGetExpiry(filename)
|
2015-09-28 04:17:12 +02:00
|
|
|
|
2015-09-28 06:25:57 +02:00
|
|
|
return isTsExpired(exp)
|
2015-09-28 04:17:12 +02:00
|
|
|
}
|