MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / capExpireTime

Function capExpireTime

pkg/filemanager/manager/entitysource/entitysource.go:774–789  ·  view source on GitHub ↗

capExpireTime make sure expire time is not too long or too short (if min or max is set)

(expire *time.Time, min, max time.Duration)

Source from the content-addressed store, hash-verified

772
773// capExpireTime make sure expire time is not too long or too short (if min or max is set)
774func capExpireTime(expire *time.Time, min, max time.Duration) *time.Time {
775 timeNow := time.Now()
776 if expire == nil {
777 return nil
778 }
779
780 cappedExpires := *expire
781 // Make sure expire time is not too long or too short
782 if min > 0 && expire.Before(timeNow.Add(min)) {
783 cappedExpires = timeNow.Add(min)
784 } else if max > 0 && expire.After(timeNow.Add(max)) {
785 cappedExpires = timeNow.Add(max)
786 }
787
788 return &cappedExpires
789}
790
791// checkPreconditions evaluates request preconditions and reports whether a precondition
792// resulted in sending StatusNotModified or StatusPreconditionFailed.

Callers 1

UrlMethod · 0.85

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected