// remove removes any existing data for the given ID, which must not
// have any references left.
493065
func (s *blockDiskStore) remove(ctx context.Context, id kbfsblock.ID) error {
	cleanup, err := s.exclusify(ctx, id)
	if err != nil {
		return err
	}
	defer cleanup()

	hasAnyRef, err := s.hasAnyRefExclusive(id)
	if err != nil {
		return err
	}
	if hasAnyRef {
		return errors.Errorf(
			"Trying to remove data for referenced block %s", id)
	}
	path := s.blockPath(id)

	err = ioutil.RemoveAll(path)
	if err != nil {
		return err
	}

	// Remove the parent (splayed) directory if it exists and is
	// empty.
	err = ioutil.Remove(filepath.Dir(path))
	if ioutil.IsNotExist(err) || ioutil.IsExist(err) {
		err = nil
	}
	return err
}
1313533
func (c *stringChanger) Remove() error {
	if c.err != nil {
		return c.err
	}
	return c.node.remove()
}
410809
func (d *Driver) Remove(id string) error {
	d.locker.Lock(id)
	defer d.locker.Unlock(id)
	if !d.DeviceSet.HasDevice(id) {
		// Consider removing a non-existing device a no-op
		// This is useful to be able to progress on container removal
		// if the underlying device has gone away due to earlier errors
		return nil
	}

	// This assumes the device has been properly Get/Put:ed and thus is unmounted
	if err := d.DeviceSet.DeleteDevice(id, false); err != nil {
		return fmt.Errorf("failed to remove device %s: %v", id, err)
	}
	return system.EnsureRemoveAll(path.Join(d.home, "mnt", id))
}
737180
func (s *Set) Remove(key interface{}) (ok bool) {
	_, ok = s.skiplist.Delete(key)
	return ok
}
266810
func (l *Layer0) Remove(id string) error {
	if !l.isLayer0(id) {
		return l.Driver.Remove(l.realID(id))
	}
	l.Lock()
	defer l.Unlock()
	var err error
	v, ok := l.volumes[id]

	if ok {
		atomic.AddInt32(&v.ref, -1)
		if v.ref == 0 {
			// Save the upper dir and blow away the rest.
			upperDir := path.Join(path.Join(l.home, l.realID(id)), "upper")
			err := os.Rename(upperDir, path.Join(v.path, "upper"))
			if err != nil {
				logrus.Warnf("Failed in rename(%v): %v", id, err)
			}
			l.Driver.Remove(l.realID(id))

			opts := make(map[string]string)
			opts[options.OptionsDeleteAfterUnmount] = "true"

			err = l.volDriver.Unmount(v.volumeID, v.path, opts)
			if l.volDriver.Type() == api.DriverType_DRIVER_TYPE_BLOCK {
				_ = l.volDriver.Detach(v.volumeID, nil)
			}
			err = os.RemoveAll(v.path)
			delete(l.volumes, v.id)
		}
	} else {
		logrus.Warnf("Failed to find layer0 vol for id %v", id)
	}
	return err
}
818737
func (this *RedisStore) Delete(id string) error {
	key := id
	if this.opts.KeyPrefix != "" {
		key = this.opts.KeyPrefix + ":" + id
	}
	_, err := this.conn.Do("DEL", key)
	if err != nil {
		return err
	}
	return nil
}
927080
func (rh *HashMap) Remove() error {
	conn := rh.pool.Get(rh.dbindex)
	// Find all hashmap keys that starts with rh.id+":"
	results, err := redis.Values(conn.Do("KEYS", rh.id+":*"))
	if err != nil {
		return err
	}
	// For each key id
	for i := 0; i < len(results); i++ {
		// Delete this key
		if _, err = conn.Do("DEL", getString(results, i)); err != nil {
			return err
		}
	}
	return nil
}
746599
func (idx *ListIndex) RemoveID(targetID []byte) error {
	value := idx.IDs.Get(targetID)
	if value == nil {
		return nil
	}

	err := idx.IndexBucket.Delete(value)
	if err != nil {
		return err
	}

	return idx.IDs.Remove(targetID)
}
164046
func (d *Driver) Remove(id string) error {
	logrus.Debugf("lcowdriver: remove: id %s", id)
	tmpID := fmt.Sprintf("%s-removing", id)
	tmpLayerPath := d.dir(tmpID)
	layerPath := d.dir(id)

	logrus.Debugf("lcowdriver: remove: id %s: layerPath %s", id, layerPath)

	// Unmount all the layers
	err := d.Put(id)
	if err != nil {
		logrus.Debugf("lcowdriver: remove id %s: failed to unmount: %s", id, err)
		return err
	}

	// for non-global case just kill the vm
	if !d.globalMode {
		if err := d.terminateServiceVM(id, fmt.Sprintf("Remove %s", id), true); err != nil {
			return err
		}
	}

	if err := os.Rename(layerPath, tmpLayerPath); err != nil && !os.IsNotExist(err) {
		return err
	}

	if err := os.RemoveAll(tmpLayerPath); err != nil {
		return err
	}

	logrus.Debugf("lcowdriver: remove: id %s: layerPath %s succeeded", id, layerPath)
	return nil
}
1019948
func (c *keyValueChanger) Remove() error {
	if c.err != nil {
		return c.err
	}
	return c.node.remove()
}
215221
func (h *HashMap) Remove() error {
	// Remove the table
	_, err := h.host.db.Exec(fmt.Sprintf("DROP TABLE %s", h.table))
	return err
}
77336
func (idx *ListIndex) Remove(value []byte) error {
	var err error
	var keys [][]byte

	c := idx.IndexBucket.Cursor()
	prefix := generatePrefix(value)

	for k, _ := c.Seek(prefix); bytes.HasPrefix(k, prefix); k, _ = c.Next() {
		keys = append(keys, k)
	}

	for _, k := range keys {
		err = idx.IndexBucket.Delete(k)
		if err != nil {
			return err
		}
	}

	return idx.IDs.RemoveID(value)
}
829194
func (s *Settings) Remove(d string) error {
	_, err := os.Stat(d)
	if !os.IsNotExist(err) {
		return os.RemoveAll(d)
	}
	return err
}
504618
func (c *LinkCache) Remove(id LinkID) {
	c.Lock()
	defer c.Unlock()
	var linkID linkIDFixed
	copy(linkID[:], id)
	elt, ok := c.cache[linkID]
	if ok {
		c.accessOrder.Remove(elt)
	}
	delete(c.cache, linkID)
}
165699
func (m *DescriptionManager) Remove(globalid string) error {
	return m.collection.Remove(bson.M{"globalid": globalid})
}
86604
func (d *Driver) Remove(id string) error {
	d.locker.Lock(id)
	defer d.locker.Unlock(id)
	if !d.DeviceSet.HasDevice(id) {
		// Consider removing a non-existing device a no-op
		// This is useful to be able to progress on container removal
		// if the underlying device has gone away due to earlier errors
		return nil
	}

	// This assumes the device has been properly Get/Put:ed and thus is unmounted
	if err := d.DeviceSet.DeleteDevice(id, false); err != nil {
		return fmt.Errorf("failed to remove device %s: %v", id, err)
	}

	// Most probably the mount point is already removed on Put()
	// (see DeviceSet.UnmountDevice()), but just in case it was not
	// let's try to remove it here as well, ignoring errors as
	// an older kernel can return EBUSY if e.g. the mount was leaked
	// to other mount namespaces. A failure to remove the container's
	// mount point is not important and should not be treated
	// as a failure to remove the container.
	mp := path.Join(d.home, "mnt", id)
	err := unix.Rmdir(mp)
	if err != nil && !os.IsNotExist(err) {
		logrus.WithField("storage-driver", "devicemapper").Warnf("unable to remove mount point %q: %s", mp, err)
	}

	return nil
}
120560
func (idx *UniqueIndex) Remove(value []byte) error {
	return idx.IndexBucket.Delete(value)
}