mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-26 04:49:18 -05:00
[filescanner] Reduce number of queries during scan
Instead of SELECT'ing timestamp and then UPDATE'ing with a ping if file is unchanged, skip the SELECT and just do a conditional UPDATE.
This commit is contained in:
parent
fe731c0993
commit
fa2b4b810f
@ -447,27 +447,25 @@ process_deferred_playlists(void)
|
||||
}
|
||||
|
||||
static void
|
||||
process_regular_file(char *file, struct stat *sb, int type, int flags, int dir_id)
|
||||
process_regular_file(const char *file, struct stat *sb, int type, int flags, int dir_id)
|
||||
{
|
||||
time_t stamp;
|
||||
int id;
|
||||
bool is_bulkscan = (flags & F_SCAN_BULK);
|
||||
struct media_file_info mfi;
|
||||
char virtual_path[PATH_MAX];
|
||||
int ret;
|
||||
|
||||
// Do not rescan metadata if file did not change since last scan
|
||||
db_file_stamp_bypath(file, &stamp, &id);
|
||||
if (stamp && (stamp >= sb->st_mtime))
|
||||
{
|
||||
db_file_ping(id);
|
||||
// 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
|
||||
ret = db_file_ping_bypath(file, sb->st_mtime);
|
||||
if ((sb->st_mtime != 0) && (ret != 0))
|
||||
return;
|
||||
}
|
||||
|
||||
// File is new or modified - (re)scan metadata and update file in library
|
||||
memset(&mfi, 0, sizeof(struct media_file_info));
|
||||
|
||||
mfi.id = id;
|
||||
// Sets id=0 if file is not in the library already
|
||||
mfi.id = db_file_id_bypath(file);
|
||||
|
||||
mfi.fname = strdup(filename_from_path(file));
|
||||
mfi.path = strdup(file);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user