// deleteRoot deletes the root entry from disk, but not the node it points to.
344107
func (ndb *nodeDB) deleteRoot(version int64, checkLatestVersion bool) {
	if checkLatestVersion && version == ndb.getLatestVersion() {
		panic("Tried to delete latest version")
	}

	key := ndb.rootKey(version)
	ndb.batch.Delete(key)
}
1042302
func (c *Client) DeleteTree(prefix string) error {
	return c.deleteRecurse(prefix, true)
}
339834
func (b *BigIP) DeleteRouteDomain(name string) error {
	return b.delete(uriNet, uriRouteDomain, name)
}
396427
func (s *Server) Delete(ctx context.Context, filePath string, version topo.Version) error {
	nodePath := path.Join(s.root, filePath)

	if version != nil {
		// We have to do a transaction. This means: if the
		// node revision is what we expect, delete it,
		// otherwise get the file. If the transaction doesn't
		// succeed, we also ask for the value of the
		// node. That way we'll know if it failed because it
		// didn't exist, or because the version was wrong.
		txnresp, err := s.cli.Txn(ctx).
			If(clientv3.Compare(clientv3.ModRevision(nodePath), "=", int64(version.(EtcdVersion)))).
			Then(clientv3.OpDelete(nodePath)).
			Else(clientv3.OpGet(nodePath)).
			Commit()
		if err != nil {
			return convertError(err, nodePath)
		}
		if !txnresp.Succeeded {
			if len(txnresp.Responses) > 0 {
				if len(txnresp.Responses[0].GetResponseRange().Kvs) > 0 {
					return topo.NewError(topo.BadVersion, nodePath)
				}
			}
			return topo.NewError(topo.NoNode, nodePath)
		}
		return nil
	}

	// This is just a regular unconditional Delete here.
	resp, err := s.cli.Delete(ctx, nodePath)
	if err != nil {
		return convertError(err, nodePath)
	}
	if resp.Deleted != 1 {
		return topo.NewError(topo.NoNode, nodePath)
	}
	return nil
}
388866
func (a *AddDeps) Root(c context.Context) *ds.Key {
	return model.AttemptKeyFromID(c, a.Auth.Id.AttemptID())
}
29710
func (c *Cache) DeleteRange(keys [][]byte, min, max int64) {
	c.init()

	c.mu.Lock()
	defer c.mu.Unlock()

	var total uint64
	for _, k := range keys {
		// Make sure key exist in the cache, skip if it does not
		e := c.store.entry(k)
		if e == nil {
			continue
		}

		total += uint64(e.size())
		// Everything is being deleted.
		if min == math.MinInt64 && max == math.MaxInt64 {
			total += uint64(len(k)) // all entries and the key.
			c.store.remove(k)
			continue
		}

		// Filter what to delete by time range.
		e.filter(min, max)
		if e.count() == 0 {
			// Nothing left in cache for that key
			total += uint64(len(k)) // all entries and the key.
			c.store.remove(k)
			continue
		}

		// Just update what is being deleted by the size of the filtered entries.
		total -= uint64(e.size())
	}
	c.tracker.DecCacheSize(total) // Decrease the live cache size.
	c.tracker.SetMemBytes(uint64(c.Size()))
}
1327303
func DeleteRule(key string) error {
	collections.ruleMutex.Lock()
	obj := collections.rules[key]
	collections.ruleMutex.Unlock()
	if obj == nil {
		log.Errorf("rule %s not found", key)
		return errors.New("rule not found")
	}

	// Check if we handle this object
	if objCallbackHandler.RuleCb == nil {
		log.Errorf("No callback registered for rule object")
		return errors.New("Invalid object type")
	}

	// Perform callback
	err := objCallbackHandler.RuleCb.RuleDelete(obj)
	if err != nil {
		log.Errorf("RuleDelete retruned error for: %+v. Err: %v", obj, err)
		return err
	}

	// delete it from modeldb
	collections.ruleMutex.Lock()
	err = obj.Delete()
	collections.ruleMutex.Unlock()
	if err != nil {
		log.Errorf("Error deleting rule %s. Err: %v", obj.Key, err)
	}

	// delete it from cache
	collections.ruleMutex.Lock()
	delete(collections.rules, key)
	collections.ruleMutex.Unlock()

	return nil
}
181300
func (m *Memory) DeleteRange(ctx context.Context, startKey, endKey []byte) error {
	if len(startKey) == 0 {
		return trace.BadParameter("missing parameter startKey")
	}
	if len(endKey) == 0 {
		return trace.BadParameter("missing parameter endKey")
	}
	m.Lock()
	defer m.Unlock()
	m.removeExpired()
	re := m.getRange(ctx, startKey, endKey, backend.NoLimit)
	for _, item := range re.Items {
		m.processEvent(backend.Event{
			Type: backend.OpDelete,
			Item: item,
		})
	}
	return nil
}
1019560
func (s *Store) DeleteNode(idx uint64, nodeName string) error {
	tx := s.db.Txn(true)
	defer tx.Abort()

	// Call the node deletion.
	if err := s.deleteNodeTxn(tx, idx, nodeName); err != nil {
		return err
	}

	tx.Commit()
	return nil
}
568990
func (f *FileStore) DeleteRange(keys [][]byte, min, max int64) error {
	var batches BatchDeleters
	f.mu.RLock()
	for _, f := range f.files {
		if f.OverlapsTimeRange(min, max) {
			batches = append(batches, f.BatchDelete())
		}
	}
	f.mu.RUnlock()

	if len(batches) == 0 {
		return nil
	}

	if err := func() error {
		if err := batches.DeleteRange(keys, min, max); err != nil {
			return err
		}

		return batches.Commit()
	}(); err != nil {
		// Rollback the deletes
		_ = batches.Rollback()
		return err
	}

	f.mu.Lock()
	f.lastModified = time.Now().UTC()
	f.lastFileStats = nil
	f.mu.Unlock()
	return nil
}
573453
func (c *ClusterManager) NodeRemoveDone(nodeID string, result error) {
	// XXX: only storage will make callback right now
	if result != nil {
		msg := fmt.Sprintf("Storage failed to decommission node %s, "+
			"error %s",
			nodeID,
			result)
		logrus.Errorf(msg)
		return
	}

	logrus.Infof("Cluster manager node remove done: node ID %s", nodeID)

	// Remove osdconfig data from etcd
	if err := c.configManager.DeleteNodeConf(nodeID); err != nil {
		logrus.Warn("error removing node from osdconfig:", err)
	}

	if err := c.deleteNodeFromDB(nodeID); err != nil {
		msg := fmt.Sprintf("Failed to delete node %s "+
			"from cluster database, error %s",
			nodeID, err)
		logrus.Errorf(msg)
	}
}
930062
func (p *NetPlugin) DeletePeerHost(node core.ServiceInfo) error {
	p.Lock()
	defer p.Unlock()
	return p.NetworkDriver.DeletePeerHost(node)
}
280848
func (s *Sensu) DeleteStash(path string) error {
	return s.delete(fmt.Sprintf("stashes/%s", path))
}
550920
func (b *BoltStore) DeleteRange(min, max uint64) error {
	minKey := uint64ToBytes(min)

	tx, err := b.conn.Begin(true)
	if err != nil {
		return err
	}
	defer tx.Rollback()

	curs := tx.Bucket(dbLogs).Cursor()
	for k, _ := curs.Seek(minKey); k != nil; k, _ = curs.Next() {
		// Handle out-of-range log index
		if bytesToUint64(k) > max {
			break
		}

		// Delete in-range log index
		if err := curs.Delete(); err != nil {
			return err
		}
	}

	return tx.Commit()
}
43076
func (d *deployerImpl) removeFromSiteRoot(ctx context.Context, subdir string, files []pkg.FileInfo, keep *pathTree) {
	dirsToCleanup := stringset.New(0)

	for _, f := range files {
		rootRel := filepath.Join(subdir, filepath.FromSlash(f.Name))
		if keep.has(rootRel) {
			continue
		}
		absPath, err := d.fs.RootRelToAbs(rootRel)
		if err != nil {
			logging.Warningf(ctx, "Refusing to remove %q: %s", f.Name, err)
			continue
		}
		if err := d.fs.EnsureFileGone(ctx, absPath); err != nil {
			logging.Warningf(ctx, "Failed to remove a file from the site root: %s", err)
		} else {
			dirsToCleanup.Add(filepath.Dir(absPath))
		}
	}

	if dirsToCleanup.Len() != 0 {
		subdirAbs, err := d.fs.RootRelToAbs(subdir)
		if err != nil {
			logging.Warningf(ctx, "Can't resolve relative %q to absolute path: %s", subdir, err)
		} else {
			removeEmptyTrees(ctx, subdirAbs, dirsToCleanup)
		}
	}
}
1110067
func (f *Factory) recursiveDelete(n *node) {
	parent := n.parent
	if parent == nil {
		return
	}
	delete(parent.children, n.name)
	if len(parent.children) == 0 {
		f.recursiveDelete(parent)
	}
}
737485
func (store *FileStore) Del(key string) {
	store.Lock()
	defer store.Unlock()
	store.del(key)
}