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
cb145d29
Commit
cb145d29
authored
Feb 24, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DirectorySave: save the flags "DEVICE_INARCHIVE" and "DEVICE_CONTAINER"
Helps avoid unnecessary archive scans during database update on a fresh MPD process.
parent
167803d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
DirectorySave.cxx
src/db/DirectorySave.cxx
+37
-0
No files found.
src/db/DirectorySave.cxx
View file @
cb145d29
...
...
@@ -31,18 +31,52 @@
#include "util/Domain.hxx"
#include <stddef.h>
#include <string.h>
#define DIRECTORY_DIR "directory: "
#define DIRECTORY_TYPE "type: "
#define DIRECTORY_MTIME "mtime: "
#define DIRECTORY_BEGIN "begin: "
#define DIRECTORY_END "end: "
static
constexpr
Domain
directory_domain
(
"directory"
);
gcc_const
static
const
char
*
DeviceToTypeString
(
unsigned
device
)
{
switch
(
device
)
{
case
DEVICE_INARCHIVE
:
return
"archive"
;
case
DEVICE_CONTAINER
:
return
"container"
;
default:
return
nullptr
;
}
}
gcc_pure
static
unsigned
ParseTypeString
(
const
char
*
type
)
{
if
(
strcmp
(
type
,
"archive"
)
==
0
)
return
DEVICE_INARCHIVE
;
else
if
(
strcmp
(
type
,
"container"
)
==
0
)
return
DEVICE_CONTAINER
;
else
return
0
;
}
void
directory_save
(
FILE
*
fp
,
const
Directory
&
directory
)
{
if
(
!
directory
.
IsRoot
())
{
const
char
*
type
=
DeviceToTypeString
(
directory
.
device
);
if
(
type
!=
nullptr
)
fprintf
(
fp
,
DIRECTORY_TYPE
"%s
\n
"
,
type
);
if
(
directory
.
mtime
!=
0
)
fprintf
(
fp
,
DIRECTORY_MTIME
"%lu
\n
"
,
(
unsigned
long
)
directory
.
mtime
);
...
...
@@ -76,6 +110,9 @@ ParseLine(Directory &directory, const char *line)
if
(
StringStartsWith
(
line
,
DIRECTORY_MTIME
))
{
directory
.
mtime
=
ParseUint64
(
line
+
sizeof
(
DIRECTORY_MTIME
)
-
1
);
}
else
if
(
StringStartsWith
(
line
,
DIRECTORY_TYPE
))
{
directory
.
device
=
ParseTypeString
(
line
+
sizeof
(
DIRECTORY_TYPE
)
-
1
);
}
else
return
false
;
...
...
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