Adding in Large Files adjustable expiry limit.
This commit is contained in:
parent
7953f31ff5
commit
605773decc
|
@ -75,6 +75,8 @@ var Config struct {
|
|||
customPagesDir string
|
||||
cleanupEveryMinutes uint64
|
||||
extraFooterText string
|
||||
maxDurationTime uint64
|
||||
maxDurationSize int64
|
||||
}
|
||||
|
||||
var Templates = make(map[string]*pongo2.Template)
|
||||
|
@ -309,6 +311,8 @@ func main() {
|
|||
"How often to clean up expired files in minutes (default is 0, which means files will be cleaned up as they are accessed)")
|
||||
flag.StringVar(&Config.extraFooterText, "extra-footer-text", "",
|
||||
"Extra text above the footer for notices.")
|
||||
flag.Uint64Var(&Config.maxDurationTime, "max-duration-time", 0, "Time till expiry for files over max-duration-size")
|
||||
flag.Int64Var(&Config.maxDurationSize, "max-duration-size", 4*1024*1024*1024, "Size of file before max-duration-time is used to determine expiry max time.")
|
||||
|
||||
iniflags.Parse()
|
||||
|
||||
|
|
12
upload.go
12
upload.go
|
@ -321,9 +321,17 @@ func processUpload(upReq UploadRequest) (upload Upload, err error) {
|
|||
// Get the rest of the metadata needed for storage
|
||||
var fileExpiry time.Time
|
||||
if upReq.expiry == 0 {
|
||||
fileExpiry = expiry.NeverExpire
|
||||
if upReq.size > Config.maxDurationSize && Config.maxDurationTime > 0 {
|
||||
fileExpiry = time.Now().Add(Config.maxDurationTime)
|
||||
} else {
|
||||
fileExpiry = expiry.NeverExpire
|
||||
}
|
||||
} else {
|
||||
fileExpiry = time.Now().Add(upReq.expiry)
|
||||
if upReq.size > Config.maxDurationSize && upReq.expiry > Config.maxDurationTime {
|
||||
fileExpiry = time.Now().Add(Config.maxDurationTime)
|
||||
} else {
|
||||
fileExpiry = time.Now().Add(upReq.expiry)
|
||||
}
|
||||
}
|
||||
|
||||
if upReq.deleteKey == "" {
|
||||
|
|
Loading…
Reference in New Issue