mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
remove unused set_all_config; expose .all_config().
This commit is contained in:
parent
4ac9ad1407
commit
7693879e3c
3 changed files with 18 additions and 15 deletions
|
@ -25,7 +25,15 @@ from anki.errors import AnkiError
|
|||
from anki.media import MediaManager, media_paths_from_col_path
|
||||
from anki.models import ModelManager
|
||||
from anki.notes import Note
|
||||
from anki.rsbackend import TR, DBError, FormatTimeSpanContext, Progress, RustBackend, pb
|
||||
from anki.rsbackend import (
|
||||
TR,
|
||||
DBError,
|
||||
FormatTimeSpanContext,
|
||||
Progress,
|
||||
RustBackend,
|
||||
from_json_bytes,
|
||||
pb,
|
||||
)
|
||||
from anki.sched import Scheduler as V1Scheduler
|
||||
from anki.schedv2 import Scheduler as V2Scheduler
|
||||
from anki.tags import TagManager
|
||||
|
@ -484,6 +492,10 @@ class Collection:
|
|||
self.setMod()
|
||||
self.conf.remove(key)
|
||||
|
||||
def all_config(self) -> Dict[str, Any]:
|
||||
"This is a debugging aid. Prefer .get_config() when you know the key you need."
|
||||
return from_json_bytes(self.backend.get_all_config())
|
||||
|
||||
# Stats
|
||||
##########################################################################
|
||||
|
||||
|
|
|
@ -214,13 +214,15 @@ service BackendService {
|
|||
rpc ClearTag(String) returns (Empty);
|
||||
rpc TagTree(Empty) returns (TagTreeNode);
|
||||
|
||||
// config/preferences
|
||||
// config
|
||||
|
||||
rpc GetConfigJson(String) returns (Json);
|
||||
rpc SetConfigJson(SetConfigJsonIn) returns (Empty);
|
||||
rpc RemoveConfig(String) returns (Empty);
|
||||
rpc SetAllConfig(Json) returns (Empty);
|
||||
rpc GetAllConfig(Empty) returns (Json);
|
||||
|
||||
// preferences
|
||||
|
||||
rpc GetPreferences(Empty) returns (Preferences);
|
||||
rpc SetPreferences(Preferences) returns (Empty);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ use pb::{sync_status_out, BackendService};
|
|||
use prost::Message;
|
||||
use serde_json::Value as JsonValue;
|
||||
use slog::warn;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashSet;
|
||||
use std::convert::TryFrom;
|
||||
use std::{
|
||||
result,
|
||||
|
@ -1413,17 +1413,6 @@ impl BackendService for Backend {
|
|||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn set_all_config(&self, input: pb::Json) -> BackendResult<Empty> {
|
||||
let val: HashMap<String, JsonValue> = serde_json::from_slice(&input.json)?;
|
||||
self.with_col(|col| {
|
||||
col.transact(None, |col| {
|
||||
col.storage
|
||||
.set_all_config(val, col.usn()?, TimestampSecs::now())
|
||||
})
|
||||
})
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
fn get_all_config(&self, _input: Empty) -> BackendResult<pb::Json> {
|
||||
self.with_col(|col| {
|
||||
let conf = col.storage.get_all_config()?;
|
||||
|
|
Loading…
Reference in a new issue