Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
19a4803b
Commit
19a4803b
authored
Oct 06, 2008
by
Eric Wong
Committed by
Max Kellermann
Oct 06, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directory: streamline deletes
Instead of relying on the shortname, just pass the song pointer to prevent redundant lookups during deletes.
parent
6aec6163
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
17 deletions
+15
-17
directory.c
src/directory.c
+15
-17
No files found.
src/directory.c
View file @
19a4803b
...
...
@@ -72,8 +72,7 @@ static enum update_return updateDirectory(Directory * directory);
static
void
deleteEmptyDirectoriesInDirectory
(
Directory
*
directory
);
static
void
removeSongFromDirectory
(
Directory
*
directory
,
const
char
*
shortname
);
static
void
delete_song
(
Directory
*
dir
,
Song
*
del
);
static
enum
update_return
addSubDirectoryToDirectory
(
Directory
*
directory
,
const
char
*
name
,
struct
stat
*
st
);
...
...
@@ -201,16 +200,12 @@ static void freeDirectory(Directory * directory)
/*getDirectoryPath(NULL); */
}
static
void
removeSongFromDirectory
(
Directory
*
directory
,
const
char
*
shortname
)
static
void
delete_song
(
Directory
*
dir
,
Song
*
del
)
{
Song
*
song
=
songvec_find
(
&
directory
->
songs
,
shortname
);
if
(
song
)
{
char
path_max_tmp
[
MPD_PATH_MAX
];
/* wasteful */
LOG
(
"removing: %s
\n
"
,
get_song_url
(
path_max_tmp
,
song
));
songvec_delete
(
&
directory
->
songs
,
song
);
freeSong
(
song
);
}
char
path_max_tmp
[
MPD_PATH_MAX
];
/* wasteful */
LOG
(
"removing: %s
\n
"
,
get_song_url
(
path_max_tmp
,
del
));
songvec_delete
(
&
dir
->
songs
,
del
);
freeSong
(
del
);
/* FIXME racy */
}
static
void
deleteEmptyDirectoriesInDirectory
(
Directory
*
directory
)
...
...
@@ -245,7 +240,7 @@ updateInDirectory(Directory * directory, const char *name)
}
else
if
(
st
.
st_mtime
!=
song
->
mtime
)
{
LOG
(
"updating %s
\n
"
,
name
);
if
(
updateSongInfo
(
song
)
<
0
)
removeSongFromDirectory
(
directory
,
shortname
);
delete_song
(
directory
,
song
);
return
UPDATE_RETURN_UPDATED
;
}
}
else
if
(
S_ISDIR
(
st
.
st_mode
))
{
...
...
@@ -297,7 +292,7 @@ removeDeletedFromDirectory(char *path_max_tmp, Directory * directory)
strcpy
(
path_max_tmp
,
song
->
url
);
if
(
!
isFile
(
path_max_tmp
,
NULL
))
{
removeSongFromDirectory
(
directory
,
song
->
url
);
delete_song
(
directory
,
song
);
ret
=
UPDATE_RETURN_UPDATED
;
}
}
...
...
@@ -311,6 +306,7 @@ static Directory *addDirectoryPathToDB(const char *utf8path)
char
*
parent
;
Directory
*
parentDirectory
;
Directory
*
directory
;
Song
*
conflicting
;
parent
=
parent_path
(
path_max_tmp
,
utf8path
);
...
...
@@ -337,7 +333,10 @@ static Directory *addDirectoryPathToDB(const char *utf8path)
/* if we're adding directory paths, make sure to delete filenames
with potentially the same name */
removeSongFromDirectory
(
parentDirectory
,
mpd_basename
(
directory
->
path
));
conflicting
=
songvec_find
(
&
parentDirectory
->
songs
,
mpd_basename
(
directory
->
path
));
if
(
conflicting
)
delete_song
(
parentDirectory
,
conflicting
);
return
directory
;
}
...
...
@@ -415,14 +414,13 @@ static enum update_return updatePath(const char *utf8path)
else
if
(
updateSongInfo
(
song
)
==
0
)
return
UPDATE_RETURN_UPDATED
;
else
{
removeSongFromDirectory
(
parentDirectory
,
song
->
url
);
delete_song
(
parentDirectory
,
song
);
return
UPDATE_RETURN_UPDATED
;
}
}
/* if updateDirectory fails, means we should delete it */
else
{
removeSongFromDirectory
(
parentDirectory
,
song
->
url
);
delete_song
(
parentDirectory
,
song
);
ret
=
UPDATE_RETURN_UPDATED
;
/* don't return, path maybe a directory now */
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment