// DeleteFavorite implements the KBFSOps interface for
// KBFSOpsStandard.
421772
func (fs *KBFSOpsStandard) DeleteFavorite(ctx context.Context,
	fav favorites.Folder) error {
	timeTrackerDone := fs.longOperationDebugDumper.Begin(ctx)
	defer timeTrackerDone()

	kbpki := fs.config.KBPKI()
	_, err := kbpki.GetCurrentSession(ctx)
	isLoggedIn := err == nil

	// Let this ops remove itself, if we have one available.
	ops := fs.getOpsByFav(fav)
	if ops != nil {
		err := ops.doFavoritesOp(ctx, fs.favs, FavoritesOpRemove, nil)
		if _, ok := err.(OpsCantHandleFavorite); !ok {
			return err
		}
		// If the ops couldn't handle the delete, fall through to
		// going directly via Favorites.
	}

	if isLoggedIn {
		err := fs.favs.Delete(ctx, fav)
		if err != nil {
			return err
		}
	}

	// TODO: Shut down the running folderBranchOps, if one exists?
	// What about open file handles?

	return nil
}
468507
func deleteFile(filename string) error {
	if fileExists(filename) {
		return os.Remove(filename)
	}
	return nil
}
790853
func (c *Client) DeletePortForwardingRule(p *DeletePortForwardingRuleParameter) (*Result, error) {
	obj, err := c.Request("deletePortForwardingRule", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Result), err
}
533461
func (service *GCSService) DeleteObjectsWithFilter(ctx context.Context, params GCSFilterParams) error {
	names, err := service.FilterObjects(ctx, params)
	if err != nil {
		return err
	}

	var objectParams GCSObjectParams
	for _, name := range names {
		objectParams = GCSObjectParams{
			Bucket: params.Bucket,
			ID:     name,
		}

		err := service.DeleteObject(ctx, objectParams)
		if err != nil {
			return err
		}
	}

	return nil
}
238997
func (k *KeybaseServiceBase) DecryptFavorites(ctx context.Context, dataToEncrypt []byte) (res []byte, err error) {
	return k.kbfsClient.DecryptFavorites(ctx, dataToEncrypt)
}
803729
func (k *SimpleFS) SimpleFSRemove(ctx context.Context,
	arg keybase1.SimpleFSRemoveArg) error {
	return k.startAsync(ctx, arg.OpID, keybase1.AsyncOps_REMOVE,
		keybase1.NewOpDescriptionWithRemove(
			keybase1.RemoveArgs{
				OpID: arg.OpID, Path: arg.Path, Recursive: arg.Recursive,
			}),
		func(ctx context.Context) (err error) {
			return k.doRemove(ctx, arg.Path, arg.Recursive)
		})
}
570527
func RemovePredicateKeyFromAlgorithmProviderMap(key string) {
	schedulerFactoryMutex.Lock()
	defer schedulerFactoryMutex.Unlock()

	for _, provider := range algorithmProviderMap {
		provider.FitPredicateKeys.Delete(key)
	}
}
530358
func (h *KBFSHandler) DecryptFavorites(ctx context.Context,
	dataToEncrypt []byte) (res []byte, err error) {
	err = encrypteddb.DecodeBox(ctx, dataToEncrypt, h.getKeyFn(), res)
	return res, err
}
6469
func (k *SimpleFS) SimpleFSListFavorites(ctx context.Context) (
	keybase1.FavoritesResult, error) {
	return k.config.KBFSOps().GetFavoritesAll(ctx)
}
474174
func (client *storageRESTClient) DeleteFile(volume, path string) error {
	values := make(url.Values)
	values.Set(storageRESTVolume, volume)
	values.Set(storageRESTFilePath, path)
	respBody, err := client.call(storageRESTMethodDeleteFile, values, nil, -1)
	defer http.DrainBody(respBody)
	return err
}
798705
func (h *Handle) ToFavorite() favorites.Folder {
	return favorites.Folder{
		Name: string(h.GetCanonicalName()),
		Type: h.Type(),
	}
}
804988
func (fs *KBFSOpsStandard) SetFavoritesHomeTLFInfo(ctx context.Context,
	info homeTLFInfo) {
	fs.favs.setHomeTLFInfo(ctx, info)
}
750139
func NewFavoriteIgnore(g *libkb.GlobalContext, arg *keybase1.FavoriteIgnoreArg) *FavoriteIgnore {
	return &FavoriteIgnore{
		arg:          arg,
		Contextified: libkb.NewContextified(g),
	}
}
136186
func (t readWriteTransaction) removeFromGlobal(gk, keyBuf, folder, device []byte, file []byte, meta *metadataTracker) []byte {
	l.Debugf("remove from global; folder=%q device=%v file=%q", folder, protocol.DeviceIDFromBytes(device), file)

	svl, err := t.Get(gk, nil)
	if err != nil {
		// We might be called to "remove" a global version that doesn't exist
		// if the first update for the file is already marked invalid.
		return keyBuf
	}

	var fl VersionList
	err = fl.Unmarshal(svl)
	if err != nil {
		l.Debugln("unmarshal error:", err)
		return keyBuf
	}

	fl, _, removedAt := fl.pop(device)
	if removedAt == -1 {
		// There is no version for the given device
		return keyBuf
	}

	if removedAt == 0 {
		// A failure to get the file here is surprising and our
		// global size data will be incorrect until a restart...
		keyBuf = t.keyer.GenerateDeviceFileKey(keyBuf, folder, device, file)
		if f, ok := t.getFileByKey(keyBuf); ok {
			meta.removeFile(protocol.GlobalDeviceID, f)
		}
	}

	if len(fl.Versions) == 0 {
		keyBuf = t.keyer.GenerateNeedFileKey(keyBuf, folder, file)
		t.Delete(keyBuf)
		t.Delete(gk)
		return keyBuf
	}

	if removedAt == 0 {
		keyBuf = t.keyer.GenerateDeviceFileKey(keyBuf, folder, fl.Versions[0].Device, file)
		global, ok := t.getFileByKey(keyBuf)
		if !ok {
			// This file must exist in the db, so this must be caused
			// by the db being closed - bail out.
			l.Debugln("File should exist:", file)
			return keyBuf
		}
		keyBuf = t.updateLocalNeed(keyBuf, folder, file, fl, global)
		meta.addFile(protocol.GlobalDeviceID, global)
	}

	l.Debugf("new global after remove: %v", fl)
	t.Put(gk, mustMarshal(&fl))

	return keyBuf
}
297493
func DeleteIsiVolume(
	ctx context.Context,
	client api.Client,
	name string) (resp *getIsiVolumesResp, err error) {

	err = client.Delete(
		ctx,
		realNamespacePath(client),
		name,
		recursiveTrueQS,
		nil,
		&resp)
	return resp, err
}
290042
func (c *KBFSContext) cleanupSocketFile() error {
	switch sock := c.kbfsSocket.(type) {
	case libkb.SocketInfo:
		sf := sock.GetBindFile()
		if exists, err := libkb.FileExists(sf); err != nil {
			return err
		} else if exists {
			c.g.Log.Debug("removing stale socket file: %s", sf)
			if err = os.Remove(sf); err != nil {
				c.g.Log.Warning("error removing stale socket file: %s", err)
				return err
			}
		}
	case nil:
		return errors.New("socket not initialized")
	default:
		return errors.New("invalid socket type")
	}
	return nil
}
1333173
func (s *ReactionsService) DeleteReaction(ctx context.Context, id int64) (*Response, error) {
	u := fmt.Sprintf("reactions/%v", id)

	req, err := s.client.NewRequest("DELETE", u, nil)
	if err != nil {
		return nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeReactionsPreview)

	return s.client.Do(ctx, req, nil)
}