mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
backend stores media folder/db locations; don't need to pass them in
This commit is contained in:
parent
58da7988c3
commit
aa832e9117
4 changed files with 5 additions and 21 deletions
|
@ -243,7 +243,5 @@ message AddFileToMediaFolderIn {
|
||||||
|
|
||||||
message SyncMediaIn {
|
message SyncMediaIn {
|
||||||
string hkey = 1;
|
string hkey = 1;
|
||||||
string media_folder = 2;
|
string endpoint = 2;
|
||||||
string media_db = 3;
|
|
||||||
string endpoint = 4;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,17 +276,8 @@ class RustBackend:
|
||||||
)
|
)
|
||||||
).add_file_to_media_folder
|
).add_file_to_media_folder
|
||||||
|
|
||||||
def sync_media(
|
def sync_media(self, hkey: str, endpoint: str) -> None:
|
||||||
self, hkey: str, media_folder: str, media_db: str, endpoint: str
|
|
||||||
) -> None:
|
|
||||||
self._run_command(
|
self._run_command(
|
||||||
pb.BackendInput(
|
pb.BackendInput(sync_media=pb.SyncMediaIn(hkey=hkey, endpoint=endpoint,)),
|
||||||
sync_media=pb.SyncMediaIn(
|
|
||||||
hkey=hkey,
|
|
||||||
media_folder=media_folder,
|
|
||||||
media_db=media_db,
|
|
||||||
endpoint=endpoint,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
release_gil=True,
|
release_gil=True,
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,7 +11,6 @@ from typing import List, Union
|
||||||
import aqt
|
import aqt
|
||||||
from anki import hooks
|
from anki import hooks
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from anki.media import media_paths_from_col_path
|
|
||||||
from anki.rsbackend import (
|
from anki.rsbackend import (
|
||||||
DBError,
|
DBError,
|
||||||
Interrupted,
|
Interrupted,
|
||||||
|
@ -76,12 +75,8 @@ class MediaSyncer:
|
||||||
self._want_stop = False
|
self._want_stop = False
|
||||||
gui_hooks.media_sync_did_start_or_stop(True)
|
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:
|
def run() -> None:
|
||||||
self.mw.col.backend.sync_media(
|
self.mw.col.backend.sync_media(hkey, self._endpoint())
|
||||||
hkey, media_folder, media_db, self._endpoint()
|
|
||||||
)
|
|
||||||
|
|
||||||
self.mw.taskman.run_in_background(run, self._on_finished)
|
self.mw.taskman.run_in_background(run, self._on_finished)
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync_media(&self, input: SyncMediaIn) -> Result<()> {
|
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| {
|
let callback = |progress: &MediaSyncProgress| {
|
||||||
self.fire_progress_callback(Progress::MediaSync(progress))
|
self.fire_progress_callback(Progress::MediaSync(progress))
|
||||||
|
|
Loading…
Reference in a new issue