backend stores media folder/db locations; don't need to pass them in

This commit is contained in:
Damien Elmes 2020-02-09 12:44:03 +10:00
parent 58da7988c3
commit aa832e9117
4 changed files with 5 additions and 21 deletions

View file

@ -243,7 +243,5 @@ message AddFileToMediaFolderIn {
message SyncMediaIn {
string hkey = 1;
string media_folder = 2;
string media_db = 3;
string endpoint = 4;
string endpoint = 2;
}

View file

@ -276,17 +276,8 @@ class RustBackend:
)
).add_file_to_media_folder
def sync_media(
self, hkey: str, media_folder: str, media_db: str, endpoint: str
) -> None:
def sync_media(self, hkey: str, endpoint: str) -> None:
self._run_command(
pb.BackendInput(
sync_media=pb.SyncMediaIn(
hkey=hkey,
media_folder=media_folder,
media_db=media_db,
endpoint=endpoint,
)
),
pb.BackendInput(sync_media=pb.SyncMediaIn(hkey=hkey, endpoint=endpoint,)),
release_gil=True,
)

View file

@ -11,7 +11,6 @@ from typing import List, Union
import aqt
from anki import hooks
from anki.lang import _
from anki.media import media_paths_from_col_path
from anki.rsbackend import (
DBError,
Interrupted,
@ -76,12 +75,8 @@ class MediaSyncer:
self._want_stop = False
gui_hooks.media_sync_did_start_or_stop(True)
(media_folder, media_db) = media_paths_from_col_path(self.mw.col.path)
def run() -> None:
self.mw.col.backend.sync_media(
hkey, media_folder, media_db, self._endpoint()
)
self.mw.col.backend.sync_media(hkey, self._endpoint())
self.mw.taskman.run_in_background(run, self._on_finished)

View file

@ -321,7 +321,7 @@ impl Backend {
}
fn sync_media(&self, input: SyncMediaIn) -> Result<()> {
let mgr = MediaManager::new(&input.media_folder, &input.media_db)?;
let mgr = MediaManager::new(&self.media_folder, &self.media_db)?;
let callback = |progress: &MediaSyncProgress| {
self.fire_progress_callback(Progress::MediaSync(progress))