in models/uploadslotDAO.go [45:66]
func WriteUploadSlot(s *UploadSlot, redis *redis.Client) error {
keyPath := fmt.Sprintf("receiver:upload_slot:%s", s.Uuid.String())
encodedData, marshalErr := json.Marshal(s)
if marshalErr != nil {
log.Printf("ERROR models.WriteUploadSlot Could not marshal object for '%s': %s", keyPath, marshalErr)
log.Printf("ERROR models.WriteUploadSlot offending data was %v", *s)
return marshalErr
}
expiry := s.Expiry.Sub(time.Now())
if expiry < 0 {
log.Printf("ERROR models.WriteUploadSlot projected expiry time for %s is in the past, can't set value", keyPath)
return errors.New("expiry time is in the past")
}
if writeErr := redis.Set(context.TODO(), keyPath, string(encodedData), expiry).Err(); writeErr != nil {
log.Printf("ERROR models.WriteUploadSlot could not write upload slot to storage: %s", writeErr)
return errors.New("could not write data")
}
return nil
}