mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
fix incorrect mark_collection_modified()
- usn shouldn't be changed - mtime is in milliseconds
This commit is contained in:
parent
bb0e5dfa93
commit
2f20be7a5a
2 changed files with 11 additions and 7 deletions
|
@ -4,7 +4,7 @@
|
||||||
/// Basic note reading/updating functionality for the media DB check.
|
/// Basic note reading/updating functionality for the media DB check.
|
||||||
use crate::err::{AnkiError, Result};
|
use crate::err::{AnkiError, Result};
|
||||||
use crate::text::strip_html_preserving_image_filenames;
|
use crate::text::strip_html_preserving_image_filenames;
|
||||||
use crate::time::i64_unix_timestamp;
|
use crate::time::{i64_unix_millis, i64_unix_secs};
|
||||||
use crate::types::{ObjID, Timestamp, Usn};
|
use crate::types::{ObjID, Timestamp, Usn};
|
||||||
use rusqlite::{params, Connection, Row, NO_PARAMS};
|
use rusqlite::{params, Connection, Row, NO_PARAMS};
|
||||||
use serde_aux::field_attributes::deserialize_number_from_string;
|
use serde_aux::field_attributes::deserialize_number_from_string;
|
||||||
|
@ -127,7 +127,7 @@ fn row_to_note(row: &Row) -> Result<Note> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn set_note(db: &Connection, note: &mut Note, note_type: &NoteType) -> Result<()> {
|
pub(super) fn set_note(db: &Connection, note: &mut Note, note_type: &NoteType) -> Result<()> {
|
||||||
note.mtime_secs = i64_unix_timestamp();
|
note.mtime_secs = i64_unix_secs();
|
||||||
// hard-coded for now
|
// hard-coded for now
|
||||||
note.usn = -1;
|
note.usn = -1;
|
||||||
let csum = field_checksum(¬e.fields()[0]);
|
let csum = field_checksum(¬e.fields()[0]);
|
||||||
|
@ -154,9 +154,6 @@ pub(super) fn set_note(db: &Connection, note: &mut Note, note_type: &NoteType) -
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn mark_collection_modified(db: &Connection) -> Result<()> {
|
pub(super) fn mark_collection_modified(db: &Connection) -> Result<()> {
|
||||||
db.execute(
|
db.execute("update col set mod=?", params![i64_unix_millis()])?;
|
||||||
"update col set usn=-1, mod=?",
|
|
||||||
params![i64_unix_timestamp()],
|
|
||||||
)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,16 @@
|
||||||
|
|
||||||
use std::time;
|
use std::time;
|
||||||
|
|
||||||
pub(crate) fn i64_unix_timestamp() -> i64 {
|
pub(crate) fn i64_unix_secs() -> i64 {
|
||||||
time::SystemTime::now()
|
time::SystemTime::now()
|
||||||
.duration_since(time::SystemTime::UNIX_EPOCH)
|
.duration_since(time::SystemTime::UNIX_EPOCH)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_secs() as i64
|
.as_secs() as i64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn i64_unix_millis() -> i64 {
|
||||||
|
time::SystemTime::now()
|
||||||
|
.duration_since(time::SystemTime::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_millis() as i64
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue