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
|
customPagesDir string
|
||||||
cleanupEveryMinutes uint64
|
cleanupEveryMinutes uint64
|
||||||
extraFooterText string
|
extraFooterText string
|
||||||
|
maxDurationTime uint64
|
||||||
|
maxDurationSize int64
|
||||||
}
|
}
|
||||||
|
|
||||||
var Templates = make(map[string]*pongo2.Template)
|
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)")
|
"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", "",
|
flag.StringVar(&Config.extraFooterText, "extra-footer-text", "",
|
||||||
"Extra text above the footer for notices.")
|
"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()
|
iniflags.Parse()
|
||||||
|
|
||||||
|
|
|
@ -321,10 +321,18 @@ func processUpload(upReq UploadRequest) (upload Upload, err error) {
|
||||||
// Get the rest of the metadata needed for storage
|
// Get the rest of the metadata needed for storage
|
||||||
var fileExpiry time.Time
|
var fileExpiry time.Time
|
||||||
if upReq.expiry == 0 {
|
if upReq.expiry == 0 {
|
||||||
|
if upReq.size > Config.maxDurationSize && Config.maxDurationTime > 0 {
|
||||||
|
fileExpiry = time.Now().Add(Config.maxDurationTime)
|
||||||
|
} else {
|
||||||
fileExpiry = expiry.NeverExpire
|
fileExpiry = expiry.NeverExpire
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if upReq.size > Config.maxDurationSize && upReq.expiry > Config.maxDurationTime {
|
||||||
|
fileExpiry = time.Now().Add(Config.maxDurationTime)
|
||||||
} else {
|
} else {
|
||||||
fileExpiry = time.Now().Add(upReq.expiry)
|
fileExpiry = time.Now().Add(upReq.expiry)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if upReq.deleteKey == "" {
|
if upReq.deleteKey == "" {
|
||||||
upReq.deleteKey = uniuri.NewLen(30)
|
upReq.deleteKey = uniuri.NewLen(30)
|
||||||
|
|
Loading…
Reference in New Issue