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
20029e7c
Commit
20029e7c
authored
Jun 13, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update_walk: move code to make_directory_if_modified()
parent
fcb79508
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
21 deletions
+39
-21
update_walk.c
src/update_walk.c
+39
-21
No files found.
src/update_walk.c
View file @
20029e7c
...
...
@@ -308,39 +308,57 @@ update_archive_file(struct directory *parent, const char *name,
}
#endif
/**
* Create the specified directory object if it does not exist already
* or if the #stat object indicates that it has been modified since
* the last update. Returns NULL when it exists already and is
* unmodified.
*
* The caller must lock the database.
*/
static
struct
directory
*
make_directory_if_modified
(
struct
directory
*
parent
,
const
char
*
name
,
const
struct
stat
*
st
)
{
struct
directory
*
directory
=
directory_get_child
(
parent
,
name
);
// directory exists already
if
(
directory
!=
NULL
)
{
if
(
directory
->
mtime
==
st
->
st_mtime
&&
!
walk_discard
)
{
/* not modified */
db_unlock
();
return
NULL
;
}
delete_directory
(
directory
);
modified
=
true
;
}
directory
=
directory_make_child
(
parent
,
name
);
directory
->
mtime
=
st
->
st_mtime
;
return
directory
;
}
static
bool
update_container_file
(
struct
directory
*
directory
,
const
char
*
name
,
const
struct
stat
*
st
,
const
struct
decoder_plugin
*
plugin
)
{
char
*
pathname
=
map_directory_child_fs
(
directory
,
name
);
db_lock
();
struct
directory
*
contdir
=
directory_get_child
(
directory
,
name
);
// directory exists already
if
(
contdir
!=
NULL
)
{
// modification time not eq. file mod. time
if
(
contdir
->
mtime
!=
st
->
st_mtime
||
walk_discard
)
{
g_message
(
"removing container file: %s"
,
pathname
);
delete_directory
(
contdir
);
contdir
=
NULL
;
modified
=
true
;
}
else
{
db_unlock
();
g_free
(
pathname
);
return
true
;
}
struct
directory
*
contdir
=
make_directory_if_modified
(
directory
,
name
,
st
);
if
(
contdir
==
NULL
)
{
/* not modified */
db_unlock
();
return
true
;
}
contdir
=
directory_make_child
(
directory
,
name
);
contdir
->
mtime
=
st
->
st_mtime
;
contdir
->
device
=
DEVICE_CONTAINER
;
db_unlock
();
char
*
const
pathname
=
map_directory_child_fs
(
directory
,
name
);
char
*
vtrack
;
unsigned
int
tnum
=
0
;
while
((
vtrack
=
plugin
->
container_scan
(
pathname
,
++
tnum
))
!=
NULL
)
{
...
...
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