fix incorrect mark_collection_modified()

- usn shouldn't be changed
- mtime is in milliseconds
This commit is contained in:
Damien Elmes 2020-03-05 14:55:03 +10:00
parent bb0e5dfa93
commit 2f20be7a5a
2 changed files with 11 additions and 7 deletions

View file

@ -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<Note> {
}
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(&note.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(())
}

View file

@ -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
}