diff --git a/pylib/tests/test_schedv1.py b/pylib/tests/test_schedv1.py index b88d3cf97..4a7e792a3 100644 --- a/pylib/tests/test_schedv1.py +++ b/pylib/tests/test_schedv1.py @@ -13,6 +13,7 @@ def getEmptyCol(): col = getEmptyColOrig() # only safe in test environment col.set_config("schedVer", 1) + col._loadScheduler() return col diff --git a/rslib/src/config.rs b/rslib/src/config.rs index 925dde90c..f84728b68 100644 --- a/rslib/src/config.rs +++ b/rslib/src/config.rs @@ -18,7 +18,7 @@ use slog::warn; /// new config variables, you do not need to add them here - /// just create an accessor function below with an appropriate /// default on missing/invalid values instead. -pub(crate) fn schema11_config_as_string() -> String { +pub(crate) fn schema11_config_as_string(creation_offset: Option) -> String { let obj = json!({ "activeDecks": [1], "curDeck": 1, @@ -33,7 +33,8 @@ pub(crate) fn schema11_config_as_string() -> String { "sortBackwards": false, "addToCur": true, "dayLearnFirst": false, - "schedVer": 1, + "schedVer": 2, + "creationOffset": creation_offset, }); serde_json::to_string(&obj).unwrap() } diff --git a/rslib/src/storage/sqlite.rs b/rslib/src/storage/sqlite.rs index 6695538de..e1144e49d 100644 --- a/rslib/src/storage/sqlite.rs +++ b/rslib/src/storage/sqlite.rs @@ -1,10 +1,10 @@ // Copyright: Ankitects Pty Ltd and contributors // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -use crate::config::schema11_config_as_string; use crate::err::Result; use crate::err::{AnkiError, DBErrorKind}; use crate::timestamp::{TimestampMillis, TimestampSecs}; +use crate::{config::schema11_config_as_string, sched::cutoff::local_minutes_west_for_stamp}; use crate::{i18n::I18n, sched::cutoff::v1_creation_date, text::without_combining}; use regex::Regex; use rusqlite::{functions::FunctionFlags, params, Connection, NO_PARAMS}; @@ -166,13 +166,18 @@ impl SqliteStorage { db.execute_batch(include_str!("schema11.sql"))?; // start at schema 11, then upgrade below let crt = v1_creation_date(); + let offset = if server { + None + } else { + Some(local_minutes_west_for_stamp(crt)) + }; db.execute( "update col set crt=?, scm=?, ver=?, conf=?", params![ crt, TimestampMillis::now(), SCHEMA_STARTING_VERSION, - &schema11_config_as_string() + &schema11_config_as_string(offset) ], )?; }