/// <summary> /// Deletes a fork, only leaves can be deleted /// </summary> /// <param name="id">Fork id to delete</param> /// <returns>success</returns> public bool DeleteFork(int id) { var forkIds = GetForkIds(); if (!forkIds.Contains(id)) { throw new ArgumentException(nameof(id)); } var fork = GetFork(id); if (fork.ReadOnly) { return(false); } if (fork.ParentId != 0) { var parent = GetFork(fork.ParentId); parent.ChildrenIds.Remove(fork.Id); SetFork(parent); } forkIds.Remove(fork.Id); SetForkIds(forkIds); KeyValueStore.FlushKeys($"{KeyGenerator.GenerateForkPattern(AppId, id)}*"); return(true); }