func UploadSlotForId()

in models/uploadslotDAO.go [17:40]


func UploadSlotForId(id uuid.UUID, redis *redis.Client) (*UploadSlot, error) {
	keyPath := fmt.Sprintf("receiver:upload_slot:%s", id.String())

	content, getErr := redis.Get(context.TODO(), keyPath).Result()
	if getErr != nil {
		log.Printf("ERROR models.UploadSlotForId could not get value for '%s': %s", keyPath, getErr)
		return nil, getErr
	}

	if content == "" {
		return nil, nil
	}

	var s UploadSlot
	unmarshalErr := json.Unmarshal([]byte(content), &s)
	if unmarshalErr != nil {
		log.Printf("ERROR models.UploadSlotForId could not parse value for '%s': %s. Deleting the corrupted value.", keyPath, unmarshalErr)
		log.Print("ERROR models.UploadSlotForId content was ", content)
		redis.Del(context.TODO(), keyPath)
		return nil, unmarshalErr
	}

	return &s, nil
}