mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-26 06:03:20 -05:00
[scan] Fix missing rescan if a file is modified quickly multiple times
If db_timestamp == file_mtime we didn't rescan, just pinged the file in the db Fixes #1782
This commit is contained in:
parent
90a79090ea
commit
59bba5e261
5
src/db.c
5
src/db.c
@ -7055,7 +7055,10 @@ db_statements_prepare_ping(const char *table)
|
|||||||
sqlite3_stmt *stmt;
|
sqlite3_stmt *stmt;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
CHECK_NULL(L_DB, query = db_mprintf("UPDATE %s SET db_timestamp = ?, disabled = 0 WHERE path = ? AND db_timestamp >= ?;", table));
|
// The last param will be the file mtime. We must not update if the mtime is
|
||||||
|
// newer or equal than the current db_timestamp, since the file may have been
|
||||||
|
// modified and must be rescanned.
|
||||||
|
CHECK_NULL(L_DB, query = db_mprintf("UPDATE %s SET db_timestamp = ?, disabled = 0 WHERE path = ? AND db_timestamp > ?;", table));
|
||||||
|
|
||||||
ret = db_blocking_prepare_v2(query, -1, &stmt, NULL);
|
ret = db_blocking_prepare_v2(query, -1, &stmt, NULL);
|
||||||
if (ret != SQLITE_OK)
|
if (ret != SQLITE_OK)
|
||||||
|
@ -572,10 +572,12 @@ process_regular_file(const char *file, struct stat *sb, int type, int flags, int
|
|||||||
char virtual_path[PATH_MAX];
|
char virtual_path[PATH_MAX];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// Will return 0 if file is not in library or if file mtime is newer than library timestamp
|
|
||||||
// - note if mtime is 0 then we always scan the file
|
|
||||||
if (!(flags & F_SCAN_METARESCAN))
|
if (!(flags & F_SCAN_METARESCAN))
|
||||||
{
|
{
|
||||||
|
// Will return 0 if file is not in library or if file mtime is not older
|
||||||
|
// than the library timestamp. If mtime is equal we must rescan, since a
|
||||||
|
// fast update may have been made, see issue #1782. If mtime is 0 then we
|
||||||
|
// always scan.
|
||||||
ret = db_file_ping_bypath(file, sb->st_mtime);
|
ret = db_file_ping_bypath(file, sb->st_mtime);
|
||||||
if ((sb->st_mtime != 0) && (ret != 0))
|
if ((sb->st_mtime != 0) && (ret != 0))
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user