[scan] Update iTunes scanner to use new filescanner util functions
This commit is contained in:
parent
46a9114948
commit
2a69869816
|
@ -21,6 +21,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -859,21 +860,14 @@ process_pls(plist_t playlists, const char *file)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
scan_itunes_itml(const char *file, time_t mtime, int dir_id)
|
||||
static bool
|
||||
itml_is_modified(const char *path, time_t mtime)
|
||||
{
|
||||
struct playlist_info *pli;
|
||||
struct stat sb;
|
||||
char buf[PATH_MAX];
|
||||
char *itml_xml;
|
||||
plist_t itml;
|
||||
plist_t node;
|
||||
int fd;
|
||||
int ret;
|
||||
int pl_id;
|
||||
|
||||
// This is special playlist that is disabled and only used for saving a timestamp
|
||||
pli = db_pl_fetch_bytitlepath(file, file);
|
||||
// This is a special playlist that is disabled and only used for saving a timestamp
|
||||
pli = db_pl_fetch_bytitlepath(path, path);
|
||||
if (pli)
|
||||
{
|
||||
// mtime == db_timestamp is also treated as a modification because some editors do
|
||||
|
@ -882,47 +876,50 @@ scan_itunes_itml(const char *file, time_t mtime, int dir_id)
|
|||
// is equal to the newly updated db_timestamp)
|
||||
if (mtime && (pli->db_timestamp > mtime))
|
||||
{
|
||||
DPRINTF(E_LOG, L_SCAN, "Unchanged iTunes XML found, not processing '%s'\n", file);
|
||||
DPRINTF(E_LOG, L_SCAN, "Unchanged iTunes XML found, not processing '%s'\n", path);
|
||||
|
||||
// TODO Protect the radio stations from purge after scan
|
||||
db_pl_ping_bymatch(file, 0);
|
||||
db_pl_ping_bymatch(path, 0);
|
||||
free_pli(pli, 0);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
DPRINTF(E_LOG, L_SCAN, "Modified iTunes XML found, processing '%s'\n", file);
|
||||
DPRINTF(E_LOG, L_SCAN, "Modified iTunes XML found, processing '%s'\n", path);
|
||||
|
||||
// Clear out everything, we will recreate
|
||||
db_pl_delete_bypath(file);
|
||||
db_pl_delete_bypath(path);
|
||||
free_pli(pli, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINTF(E_LOG, L_SCAN, "New iTunes XML found, processing: '%s'\n", file);
|
||||
DPRINTF(E_LOG, L_SCAN, "New iTunes XML found, processing: '%s'\n", path);
|
||||
}
|
||||
|
||||
CHECK_NULL(L_SCAN, pli = calloc(1, sizeof(struct playlist_info)));
|
||||
|
||||
pli->type = PL_PLAIN;
|
||||
pli->title = strdup(file);
|
||||
pli->path = strdup(file);
|
||||
snprintf(buf, sizeof(buf), "/file:%s", file);
|
||||
pli->virtual_path = strip_extension(buf);
|
||||
pli->directory_id = dir_id;
|
||||
|
||||
ret = db_pl_add(pli, (int *)&pli->id);
|
||||
if (ret < 0)
|
||||
pl_id = playlist_add(path);
|
||||
if (pl_id < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_SCAN, "Error adding iTunes XML meta playlist '%s'\n", file);
|
||||
|
||||
free_pli(pli, 0);
|
||||
return;
|
||||
DPRINTF(E_LOG, L_SCAN, "Error adding iTunes XML meta playlist '%s'\n", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Disable, only used for saving timestamp
|
||||
db_pl_disable_bypath(file, STRIP_NONE, 0);
|
||||
db_pl_disable_bypath(path, STRIP_NONE, 0);
|
||||
|
||||
free_pli(pli, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
scan_itunes_itml(const char *file, time_t mtime, int dir_id)
|
||||
{
|
||||
struct stat sb;
|
||||
char *itml_xml;
|
||||
plist_t itml;
|
||||
plist_t node;
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
if (!itml_is_modified(file, mtime))
|
||||
return;
|
||||
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
|
|
Loading…
Reference in New Issue