mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Drop legacy schema option
This commit is contained in:
parent
28fa74feb3
commit
6d34d19808
6 changed files with 2 additions and 46 deletions
|
@ -41,9 +41,6 @@ message OpenCollectionRequest {
|
|||
string collection_path = 1;
|
||||
string media_folder_path = 2;
|
||||
string media_db_path = 3;
|
||||
|
||||
// temporary option for AnkiDroid
|
||||
bool force_schema11 = 99;
|
||||
}
|
||||
|
||||
message CloseCollectionRequest {
|
||||
|
|
|
@ -316,7 +316,6 @@ class Collection(DeprecatedNamesMixin):
|
|||
collection_path=self.path,
|
||||
media_folder_path=media_dir,
|
||||
media_db_path=media_db,
|
||||
force_schema11=False,
|
||||
)
|
||||
self.db = DBProxy(weakref.proxy(self._backend))
|
||||
self.db.begin()
|
||||
|
|
|
@ -19,7 +19,6 @@ impl BackendCollectionService for Backend {
|
|||
|
||||
let mut builder = CollectionBuilder::new(input.collection_path);
|
||||
builder
|
||||
.set_force_schema11(input.force_schema11)
|
||||
.set_media_paths(input.media_folder_path, input.media_db_path)
|
||||
.set_server(self.server)
|
||||
.set_tr(self.tr.clone())
|
||||
|
|
|
@ -40,8 +40,6 @@ pub struct CollectionBuilder {
|
|||
server: Option<bool>,
|
||||
tr: Option<I18n>,
|
||||
check_integrity: bool,
|
||||
// temporary option for AnkiDroid
|
||||
force_schema11: Option<bool>,
|
||||
progress_handler: Option<Arc<Mutex<ProgressState>>>,
|
||||
}
|
||||
|
||||
|
@ -63,14 +61,7 @@ impl CollectionBuilder {
|
|||
let server = self.server.unwrap_or_default();
|
||||
let media_folder = self.media_folder.clone().unwrap_or_default();
|
||||
let media_db = self.media_db.clone().unwrap_or_default();
|
||||
let force_schema11 = self.force_schema11.unwrap_or_default();
|
||||
let storage = SqliteStorage::open_or_create(
|
||||
&col_path,
|
||||
&tr,
|
||||
server,
|
||||
self.check_integrity,
|
||||
force_schema11,
|
||||
)?;
|
||||
let storage = SqliteStorage::open_or_create(&col_path, &tr, server, self.check_integrity)?;
|
||||
let col = Collection {
|
||||
storage,
|
||||
col_path,
|
||||
|
@ -119,11 +110,6 @@ impl CollectionBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn set_force_schema11(&mut self, force: bool) -> &mut Self {
|
||||
self.force_schema11 = Some(force);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_check_integrity(&mut self, check_integrity: bool) -> &mut Self {
|
||||
self.check_integrity = check_integrity;
|
||||
self
|
||||
|
|
|
@ -777,7 +777,7 @@ mod test {
|
|||
fn add_card() {
|
||||
let tr = I18n::template_only();
|
||||
let storage =
|
||||
SqliteStorage::open_or_create(Path::new(":memory:"), &tr, false, false, false).unwrap();
|
||||
SqliteStorage::open_or_create(Path::new(":memory:"), &tr, false, false).unwrap();
|
||||
let mut card = Card::default();
|
||||
storage.add_card(&mut card).unwrap();
|
||||
let id1 = card.id;
|
||||
|
|
|
@ -258,7 +258,6 @@ impl SqliteStorage {
|
|||
tr: &I18n,
|
||||
server: bool,
|
||||
check_integrity: bool,
|
||||
force_schema11: bool,
|
||||
) -> Result<Self> {
|
||||
let db = open_or_create_collection_db(path)?;
|
||||
let (create, ver) = schema_version(&db)?;
|
||||
|
@ -311,13 +310,6 @@ impl SqliteStorage {
|
|||
|
||||
let storage = Self { db };
|
||||
|
||||
if force_schema11 {
|
||||
if create || upgrade {
|
||||
storage.commit_trx()?;
|
||||
}
|
||||
return storage_with_schema11(storage, ver);
|
||||
}
|
||||
|
||||
if create || upgrade {
|
||||
storage.upgrade_to_latest_schema(ver, server)?;
|
||||
}
|
||||
|
@ -438,20 +430,3 @@ impl SqliteStorage {
|
|||
self.db.query_row(sql, [], |r| r.get(0)).map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
fn storage_with_schema11(storage: SqliteStorage, ver: u8) -> Result<SqliteStorage> {
|
||||
if ver != 11 {
|
||||
if ver != SCHEMA_MAX_VERSION {
|
||||
// partially upgraded; need to fully upgrade before downgrading
|
||||
storage.begin_trx()?;
|
||||
storage.upgrade_to_latest_schema(ver, false)?;
|
||||
storage.commit_trx()?;
|
||||
}
|
||||
storage.downgrade_to(SchemaVersion::V11)?;
|
||||
}
|
||||
// Requery uses "TRUNCATE" by default if WAL is not enabled.
|
||||
// We copy this behaviour here. See https://github.com/ankidroid/Anki-Android/pull/7977 for
|
||||
// analysis. We may be able to enable WAL at a later time.
|
||||
storage.db.pragma_update(None, "journal_mode", "TRUNCATE")?;
|
||||
Ok(storage)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue