update: don't sanitize the path again
directory_update_init() has to be called with a path that is already sanitized. Don't call sanitizePathDup() again in updatePath().
This commit is contained in:
parent
a79bd723e2
commit
4409c34a8c
16
src/update.c
16
src/update.c
@ -373,19 +373,15 @@ addParentPathToDB(const char *utf8path)
|
|||||||
return directory;
|
return directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum update_return updatePath(const char *utf8path)
|
static enum update_return updatePath(const char *path)
|
||||||
{
|
{
|
||||||
struct directory *directory;
|
struct directory *directory;
|
||||||
struct directory *parentDirectory;
|
struct directory *parentDirectory;
|
||||||
struct song *song;
|
struct song *song;
|
||||||
char *path = sanitizePathDup(utf8path);
|
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
enum update_return ret = UPDATE_RETURN_NOUPDATE;
|
enum update_return ret = UPDATE_RETURN_NOUPDATE;
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
|
|
||||||
if (NULL == path)
|
|
||||||
return UPDATE_RETURN_ERROR;
|
|
||||||
|
|
||||||
/* if path is in the DB try to update it, or else delete it */
|
/* if path is in the DB try to update it, or else delete it */
|
||||||
if ((directory = db_get_directory(path))) {
|
if ((directory = db_get_directory(path))) {
|
||||||
parentDirectory = directory->parent;
|
parentDirectory = directory->parent;
|
||||||
@ -393,13 +389,11 @@ static enum update_return updatePath(const char *utf8path)
|
|||||||
/* if this update directory is successfull, we are done */
|
/* if this update directory is successfull, we are done */
|
||||||
ret = updateDirectory(directory);
|
ret = updateDirectory(directory);
|
||||||
if (ret != UPDATE_RETURN_ERROR) {
|
if (ret != UPDATE_RETURN_ERROR) {
|
||||||
free(path);
|
|
||||||
directory_sort(directory);
|
directory_sort(directory);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/* we don't want to delete the root directory */
|
/* we don't want to delete the root directory */
|
||||||
else if (directory == db_get_root()) {
|
else if (directory == db_get_root()) {
|
||||||
free(path);
|
|
||||||
clear_directory(directory);
|
clear_directory(directory);
|
||||||
return UPDATE_RETURN_NOUPDATE;
|
return UPDATE_RETURN_NOUPDATE;
|
||||||
}
|
}
|
||||||
@ -413,16 +407,14 @@ static enum update_return updatePath(const char *utf8path)
|
|||||||
} else if ((song = get_get_song(path))) {
|
} else if ((song = get_get_song(path))) {
|
||||||
parentDirectory = song->parent;
|
parentDirectory = song->parent;
|
||||||
if (!parentDirectory->stat
|
if (!parentDirectory->stat
|
||||||
&& statDirectory(parentDirectory) < 0) {
|
&& statDirectory(parentDirectory) < 0)
|
||||||
free(path);
|
|
||||||
return UPDATE_RETURN_NOUPDATE;
|
return UPDATE_RETURN_NOUPDATE;
|
||||||
}
|
|
||||||
/* if this song update is successful, we are done */
|
/* if this song update is successful, we are done */
|
||||||
else if (!inodeFoundInParent(parentDirectory->parent,
|
else if (!inodeFoundInParent(parentDirectory->parent,
|
||||||
parentDirectory->inode,
|
parentDirectory->inode,
|
||||||
parentDirectory->device) &&
|
parentDirectory->device) &&
|
||||||
isMusic(song_get_url(song, path_max_tmp), &mtime, 0)) {
|
isMusic(song_get_url(song, path_max_tmp), &mtime, 0)) {
|
||||||
free(path);
|
|
||||||
if (song->mtime == mtime)
|
if (song->mtime == mtime)
|
||||||
return UPDATE_RETURN_NOUPDATE;
|
return UPDATE_RETURN_NOUPDATE;
|
||||||
else if (song_file_update(song))
|
else if (song_file_update(song))
|
||||||
@ -457,8 +449,6 @@ static enum update_return updatePath(const char *utf8path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(path);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user