diff --git a/rslib/src/media/col.rs b/rslib/src/media/col.rs index 20b0e7a88..a563bb93e 100644 --- a/rslib/src/media/col.rs +++ b/rslib/src/media/col.rs @@ -4,7 +4,7 @@ /// Basic note reading/updating functionality for the media DB check. use crate::err::{AnkiError, Result}; 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 rusqlite::{params, Connection, Row, NO_PARAMS}; use serde_aux::field_attributes::deserialize_number_from_string; @@ -127,7 +127,7 @@ fn row_to_note(row: &Row) -> 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 note.usn = -1; 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<()> { - db.execute( - "update col set usn=-1, mod=?", - params![i64_unix_timestamp()], - )?; + db.execute("update col set mod=?", params![i64_unix_millis()])?; Ok(()) } diff --git a/rslib/src/time.rs b/rslib/src/time.rs index fcdede0d2..8d9084c45 100644 --- a/rslib/src/time.rs +++ b/rslib/src/time.rs @@ -3,9 +3,16 @@ use std::time; -pub(crate) fn i64_unix_timestamp() -> i64 { +pub(crate) fn i64_unix_secs() -> i64 { time::SystemTime::now() .duration_since(time::SystemTime::UNIX_EPOCH) .unwrap() .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 +}