// importStatus imports a single status, also adding it to the statuses node.
// Returns true if we already had the status in the database.
19046
func (r *run) importStatus(listNode *importer.Object, st *mastodon.Status) (bool, error) {
	select {
	case <-r.Context().Done():
		return false, r.Context().Err()
	default:
	}

	// We store child nodes by their URI, since the URI is supposed to be an
	// unchanging, globally unique identifier for the status
	statusNode, err := listNode.ChildPathObject(st.URI)
	if err != nil {
		return false, err
	}

	if r.incremental && statusNode.Attr(attrURI) == st.URI {
		return true, nil
	}

	attrs := []string{
		nodeattr.Type, "mastodon:status",
		attrURI, st.URI,
		nodeattr.URL, st.URL,
		nodeattr.Content, st.Content,
		nodeattr.StartDate, schema.RFC3339FromTime(st.CreatedAt),
	}

	if st.SpoilerText != "" {
		attrs = append(attrs, attrSpoilerText, st.SpoilerText)
	}

	filenames := make(map[string]int)

	for i, att := range st.MediaAttachments {
		// All media for a local user will be local
		resp, err := ctxutil.Client(r.Context()).Get(att.URL)
		if err != nil {
			return false, err
		}

		if resp.StatusCode != http.StatusOK {
			return false, fmt.Errorf("failed fetching attachment %s with HTTP status %s", att.URL, resp.Status)
		}

		fileRef, err := schema.WriteFileFromReader(r.Context(), r.Host.Target(), "", resp.Body)
		resp.Body.Close()
		if err != nil {
			return false, err
		}

		filename := path.Base(att.URL)
		filenames[filename]++

		// A status can have several different attachments with the same
		// filename. We add numbers to the path to diffirentiate them if that's
		// the case
		if filenames[filename] > 1 {
			ext := path.Ext(filename)
			filename = fmt.Sprintf("%s%d%s", strings.TrimSuffix(filename, ext), filenames[filename], ext)
		}

		attrs = append(attrs, fmt.Sprintf("camliPath:%v", filename), fileRef.String())

		// The first image gets to be the preview image for the node
		if i == 0 {
			attrs = append(attrs, "camliContentImage", fileRef.String())
		}

		log.Printf("mastodon: adding attachment %s to permanode %s for status %s", fileRef.String(), statusNode.PermanodeRef(), st.URI)

	}

	changed, err := statusNode.SetAttrs2(attrs...)
	if err == nil && changed {
		log.Printf("mastodon: Imported status %s to %s", st.URI, statusNode.PermanodeRef())
	}

	return !changed, err

}
886927
func (s *SetStatusInput) SetStatus(v string) *SetStatusInput {
	s.Status = &v
	return s
}
89034
func (registry *Registry) CheckStatus() map[string]string { // TODO(stevvooe) this needs a proper type
	registry.mu.RLock()
	defer registry.mu.RUnlock()
	statusKeys := make(map[string]string)
	for k, v := range registry.registeredChecks {
		err := v.Check()
		if err != nil {
			statusKeys[k] = err.Error()
		}
	}

	return statusKeys
}
298957
func (s *StateStore) UpdateNodeStatus(index uint64, nodeID, status string, event *structs.NodeEvent) error {
	txn := s.db.Txn(true)
	defer txn.Abort()

	// Lookup the node
	existing, err := txn.First("nodes", "id", nodeID)
	if err != nil {
		return fmt.Errorf("node lookup failed: %v", err)
	}
	if existing == nil {
		return fmt.Errorf("node not found")
	}

	// Copy the existing node
	existingNode := existing.(*structs.Node)
	copyNode := existingNode.Copy()

	// Add the event if given
	if event != nil {
		appendNodeEvents(index, copyNode, []*structs.NodeEvent{event})
	}

	// Update the status in the copy
	copyNode.Status = status
	copyNode.ModifyIndex = index

	// Insert the node
	if err := txn.Insert("nodes", copyNode); err != nil {
		return fmt.Errorf("node update failed: %v", err)
	}
	if err := txn.Insert("index", &IndexEntry{"nodes", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}

	txn.Commit()
	return nil
}
552487
func (c *FakeVolumeAttachments) UpdateStatus(volumeAttachment *v1alpha1.VolumeAttachment) (*v1alpha1.VolumeAttachment, error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootUpdateSubresourceAction(volumeattachmentsResource, "status", volumeAttachment), &v1alpha1.VolumeAttachment{})
	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.VolumeAttachment), err
}
783626
func (s *DescribeThingRegistrationTaskOutput) SetStatus(v string) *DescribeThingRegistrationTaskOutput {
	s.Status = &v
	return s
}
959904
func (p *PagesBuild) GetStatus() string {
	if p == nil || p.Status == nil {
		return ""
	}
	return *p.Status
}
135980
func (c *FakeCiliumNetworkPolicies) UpdateStatus(ciliumNetworkPolicy *v2.CiliumNetworkPolicy) (*v2.CiliumNetworkPolicy, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(ciliumnetworkpoliciesResource, "status", c.ns, ciliumNetworkPolicy), &v2.CiliumNetworkPolicy{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v2.CiliumNetworkPolicy), err
}
634556
func (check *Check) UpdateStatus(status int, err error) {
	if err != nil {
		log.Debugf("Error executing check, status UNKNOWN: (id %s)", check.ID)
		check.Status = UNKNOWN
		check.LastError = err
	} else {
		check.Status = status
	}

	if status == HEALTHY {
		check.Count = 0
		return
	}

	check.Count = check.Count + 1

	if check.Count >= check.MaxCount {
		check.Status = FAILED
	}
}
7822
func (info *RestoreInfo) Status() (RestoreStatus, error) {
	restoreInfo, closer := info.st.db().GetCollection(restoreInfoC)
	defer closer()

	var doc struct {
		Status RestoreStatus `bson:"status"`
	}
	err := restoreInfo.FindId(currentRestoreId).One(&doc)
	switch errors.Cause(err) {
	case nil:
	case mgo.ErrNotFound:
		return RestoreNotActive, nil
	default:
		return "", errors.Annotate(err, "cannot read restore info")
	}

	if err := doc.Status.Validate(); err != nil {
		return "", errors.Trace(err)
	}
	return doc.Status, nil
}
131623
func (sb *SafeBrowser) Status() (Stats, error) {
	stats := Stats{
		QueriesByDatabase: atomic.LoadInt64(&sb.stats.QueriesByDatabase),
		QueriesByCache:    atomic.LoadInt64(&sb.stats.QueriesByCache),
		QueriesByAPI:      atomic.LoadInt64(&sb.stats.QueriesByAPI),
		QueriesFail:       atomic.LoadInt64(&sb.stats.QueriesFail),
		DatabaseUpdateLag: sb.db.UpdateLag(),
	}
	return stats, sb.db.Status()
}
92082
func (c *FakeTemplateInstances) UpdateStatus(templateInstance *template.TemplateInstance) (*template.TemplateInstance, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(templateinstancesResource, "status", c.ns, templateInstance), &template.TemplateInstance{})

	if obj == nil {
		return nil, err
	}
	return obj.(*template.TemplateInstance), err
}
352910
func (c *FakeNamespaces) UpdateStatus(namespace *corev1.Namespace) (*corev1.Namespace, error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootUpdateSubresourceAction(namespacesResource, "status", namespace), &corev1.Namespace{})
	if obj == nil {
		return nil, err
	}
	return obj.(*corev1.Namespace), err
}
1164897
func (c *Commit) FileStatus() (*CommitFileStatus, error) {
	return GetCommitFileStatus(c.repo.Path, c.ID.String())
}
861607
func (c *FakeRoutes) UpdateStatus(routeResource *route.Route) (*route.Route, error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateSubresourceAction(routesResource, "status", c.ns, routeResource), &route.Route{})

	if obj == nil {
		return nil, err
	}
	return obj.(*route.Route), err
}
294770
func getStatus(db Database, globalKey, badge string) (_ status.StatusInfo, err error) {
	defer errors.DeferredAnnotatef(&err, "cannot get status")
	statuses, closer := db.GetCollection(statusesC)
	defer closer()

	var doc statusDoc
	err = statuses.FindId(globalKey).One(&doc)
	if err == mgo.ErrNotFound {
		return status.StatusInfo{}, errors.NotFoundf(badge)
	} else if err != nil {
		return status.StatusInfo{}, errors.Trace(err)
	}

	return status.StatusInfo{
		Status:  doc.Status,
		Message: doc.StatusInfo,
		Data:    utils.UnescapeKeys(doc.StatusData),
		Since:   unixNanoToTime(doc.Updated),
	}, nil
}
310490
func (s *TrustedAdvisorCheckRefreshStatus) SetStatus(v string) *TrustedAdvisorCheckRefreshStatus {
	s.Status = &v
	return s
}