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
476578d2
Commit
476578d2
authored
Oct 09, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: removed addToDirectory()
Use updateInDirectory() instead of addToDirectory(). Eliminate a duplicate stat() in updateInDirectory() by calling song_file_update() directly.
parent
60d122e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
39 deletions
+12
-39
update.c
src/update.c
+12
-39
No files found.
src/update.c
View file @
476578d2
...
...
@@ -187,35 +187,6 @@ addSubDirectoryToDirectory(struct directory *directory,
}
static
enum
update_return
addToDirectory
(
struct
directory
*
directory
,
const
char
*
name
)
{
struct
stat
st
;
if
(
myStat
(
name
,
&
st
))
{
DEBUG
(
"failed to stat %s: %s
\n
"
,
name
,
strerror
(
errno
));
return
UPDATE_RETURN_ERROR
;
}
if
(
S_ISREG
(
st
.
st_mode
)
&&
hasMusicSuffix
(
name
,
0
)
&&
isMusic
(
name
,
NULL
,
0
))
{
struct
song
*
song
;
const
char
*
shortname
=
mpd_basename
(
name
);
if
(
!
(
song
=
song_file_load
(
shortname
,
directory
)))
return
-
1
;
songvec_add
(
&
directory
->
songs
,
song
);
LOG
(
"added %s
\n
"
,
name
);
return
UPDATE_RETURN_UPDATED
;
}
else
if
(
S_ISDIR
(
st
.
st_mode
))
{
return
addSubDirectoryToDirectory
(
directory
,
name
,
&
st
);
}
DEBUG
(
"addToDirectory: %s is not a directory or music
\n
"
,
name
);
return
UPDATE_RETURN_ERROR
;
}
static
enum
update_return
updateInDirectory
(
struct
directory
*
directory
,
const
char
*
name
)
{
struct
song
*
song
;
...
...
@@ -228,7 +199,12 @@ updateInDirectory(struct directory *directory, const char *name)
const
char
*
shortname
=
mpd_basename
(
name
);
if
(
!
(
song
=
songvec_find
(
&
directory
->
songs
,
shortname
)))
{
addToDirectory
(
directory
,
name
);
song
=
song_file_load
(
shortname
,
directory
);
if
(
song
==
NULL
)
return
-
1
;
songvec_add
(
&
directory
->
songs
,
song
);
LOG
(
"added %s
\n
"
,
name
);
return
UPDATE_RETURN_UPDATED
;
}
else
if
(
st
.
st_mtime
!=
song
->
mtime
)
{
LOG
(
"updating %s
\n
"
,
name
);
...
...
@@ -247,6 +223,8 @@ updateInDirectory(struct directory *directory, const char *name)
}
}
DEBUG
(
"update: %s is not a directory or music
\n
"
,
name
);
return
UPDATE_RETURN_NOUPDATE
;
}
...
...
@@ -293,14 +271,9 @@ updateDirectory(struct directory *directory)
if
(
!
isRootDirectory
(
directory
->
path
))
utf8
=
pfx_dir
(
path_max_tmp
,
utf8
,
strlen
(
utf8
),
dirname
,
strlen
(
dirname
));
if
(
was_empty
)
{
if
(
addToDirectory
(
directory
,
path_max_tmp
)
==
UPDATE_RETURN_UPDATED
)
ret
=
UPDATE_RETURN_UPDATED
;
}
else
{
if
(
updateInDirectory
(
directory
,
path_max_tmp
)
>
0
)
ret
=
UPDATE_RETURN_UPDATED
;
}
if
(
updateInDirectory
(
directory
,
path_max_tmp
)
==
UPDATE_RETURN_UPDATED
)
ret
=
UPDATE_RETURN_UPDATED
;
}
closedir
(
dir
);
...
...
@@ -446,7 +419,7 @@ static enum update_return updatePath(const char *utf8path)
}
else
if
(
0
==
inodeFoundInParent
(
parentDirectory
->
parent
,
parentDirectory
->
inode
,
parentDirectory
->
device
)
&&
addTo
Directory
(
parentDirectory
,
path
)
&&
updateIn
Directory
(
parentDirectory
,
path
)
==
UPDATE_RETURN_UPDATED
)
{
ret
=
UPDATE_RETURN_UPDATED
;
}
...
...
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