Always scan for media changes
The check runs in the background, and the dentry cache and SQLite page cache should make this more efficient after the first run. Closes #1736
This commit is contained in:
parent
52f52724fa
commit
09cb8b3cf6
@ -8,8 +8,7 @@ use crate::{
|
|||||||
media::{
|
media::{
|
||||||
database::{MediaDatabaseContext, MediaEntry},
|
database::{MediaDatabaseContext, MediaEntry},
|
||||||
files::{
|
files::{
|
||||||
filename_if_normalized, mtime_as_i64, sha1_of_file, MEDIA_SYNC_FILESIZE_LIMIT,
|
filename_if_normalized, sha1_of_file, MEDIA_SYNC_FILESIZE_LIMIT, NONSYNCABLE_FILENAME,
|
||||||
NONSYNCABLE_FILENAME,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
@ -59,17 +58,7 @@ where
|
|||||||
|
|
||||||
pub(super) fn register_changes(&mut self, ctx: &mut MediaDatabaseContext) -> Result<()> {
|
pub(super) fn register_changes(&mut self, ctx: &mut MediaDatabaseContext) -> Result<()> {
|
||||||
ctx.transact(|ctx| {
|
ctx.transact(|ctx| {
|
||||||
// folder mtime unchanged?
|
debug!(self.log, "begin change check");
|
||||||
let dirmod = mtime_as_i64(self.media_folder)?;
|
|
||||||
|
|
||||||
let mut meta = ctx.get_meta()?;
|
|
||||||
debug!(self.log, "begin change check"; "folder_mod" => dirmod, "db_mod" => meta.folder_mtime);
|
|
||||||
if dirmod == meta.folder_mtime {
|
|
||||||
debug!(self.log, "skip check");
|
|
||||||
return Ok(());
|
|
||||||
} else {
|
|
||||||
meta.folder_mtime = dirmod;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mtimes = ctx.all_mtimes()?;
|
let mtimes = ctx.all_mtimes()?;
|
||||||
self.checked += mtimes.len();
|
self.checked += mtimes.len();
|
||||||
@ -80,8 +69,6 @@ where
|
|||||||
self.add_updated_entries(ctx, changed)?;
|
self.add_updated_entries(ctx, changed)?;
|
||||||
self.remove_deleted_files(ctx, removed)?;
|
self.remove_deleted_files(ctx, removed)?;
|
||||||
|
|
||||||
ctx.set_meta(&meta)?;
|
|
||||||
|
|
||||||
// unconditional fire at end of op for accurate counts
|
// unconditional fire at end of op for accurate counts
|
||||||
self.fire_progress_cb()?;
|
self.fire_progress_cb()?;
|
||||||
|
|
||||||
|
@ -56,6 +56,10 @@ pub struct MediaEntry {
|
|||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct MediaDatabaseMetadata {
|
pub struct MediaDatabaseMetadata {
|
||||||
|
/// The syncing code no longer uses this; files are scanned for
|
||||||
|
/// indiscriminately. After this has been in production for a while
|
||||||
|
/// without reports of speed regressions, we should remove the rest
|
||||||
|
/// of the code that refers to this.
|
||||||
pub folder_mtime: i64,
|
pub folder_mtime: i64,
|
||||||
pub last_sync_usn: i32,
|
pub last_sync_usn: i32,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user