MCPcopy Create free account
hub / github.com/MG-RAST/Shock / SetExpiration

Method SetExpiration

shock-server/node/node.go:363–383  ·  view source on GitHub ↗
(expire string)

Source from the content-addressed store, hash-verified

361}
362
363func (node *Node) SetExpiration(expire string) (err error) {
364 parts := ExpireRegex.FindStringSubmatch(expire)
365 if len(parts) == 0 {
366 return errors.New("expiration format is invalid")
367 }
368 var expireTime time.Duration
369 expireNum, _ := strconv.Atoi(parts[1])
370 currTime := time.Now()
371
372 switch parts[2] {
373 case "M":
374 expireTime = time.Duration(expireNum) * time.Minute
375 case "H":
376 expireTime = time.Duration(expireNum) * time.Hour
377 case "D":
378 expireTime = time.Duration(expireNum*24) * time.Hour
379 }
380
381 node.Expiration = currTime.Add(expireTime)
382 return
383}
384
385func (node *Node) SetAttributes(attr file.FormFile) (err error) {
386 defer attr.Remove()

Callers 1

UpdateMethod · 0.95

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected