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
6f37f575
Commit
6f37f575
authored
Feb 11, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/PlaylistInfo: use std::chrono::system_clock::time_point
parent
9d0a71f2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
17 deletions
+32
-17
PlaylistDatabase.cxx
src/PlaylistDatabase.cxx
+10
-7
PlaylistFile.cxx
src/PlaylistFile.cxx
+1
-1
OtherCommands.cxx
src/command/OtherCommands.cxx
+2
-1
PlaylistCommands.cxx
src/command/PlaylistCommands.cxx
+2
-1
DatabasePrint.cxx
src/db/DatabasePrint.cxx
+2
-1
PlaylistInfo.hxx
src/db/PlaylistInfo.hxx
+9
-4
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+5
-1
Walk.cxx
src/db/update/Walk.cxx
+1
-1
No files found.
src/PlaylistDatabase.cxx
View file @
6f37f575
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "fs/io/TextFile.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "util/StringStrip.hxx"
#include "util/StringStrip.hxx"
#include "util/ChronoUtil.hxx"
#include "util/RuntimeError.hxx"
#include "util/RuntimeError.hxx"
#include <string.h>
#include <string.h>
...
@@ -31,17 +32,19 @@
...
@@ -31,17 +32,19 @@
void
void
playlist_vector_save
(
BufferedOutputStream
&
os
,
const
PlaylistVector
&
pv
)
playlist_vector_save
(
BufferedOutputStream
&
os
,
const
PlaylistVector
&
pv
)
{
{
for
(
const
PlaylistInfo
&
pi
:
pv
)
for
(
const
PlaylistInfo
&
pi
:
pv
)
{
os
.
Format
(
PLAYLIST_META_BEGIN
"%s
\n
"
os
.
Format
(
PLAYLIST_META_BEGIN
"%s
\n
"
,
pi
.
name
.
c_str
());
"mtime: %li
\n
"
if
(
!
IsNegative
(
pi
.
mtime
))
"playlist_end
\n
"
,
os
.
Format
(
"mtime: %li
\n
"
,
pi
.
name
.
c_str
(),
(
long
)
pi
.
mtime
);
(
long
)
std
::
chrono
::
system_clock
::
to_time_t
(
pi
.
mtime
));
os
.
Write
(
"playlist_end
\n
"
);
}
}
}
void
void
playlist_metadata_load
(
TextFile
&
file
,
PlaylistVector
&
pv
,
const
char
*
name
)
playlist_metadata_load
(
TextFile
&
file
,
PlaylistVector
&
pv
,
const
char
*
name
)
{
{
PlaylistInfo
pm
(
name
,
0
);
PlaylistInfo
pm
(
name
);
char
*
line
,
*
colon
;
char
*
line
,
*
colon
;
const
char
*
value
;
const
char
*
value
;
...
@@ -57,7 +60,7 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name)
...
@@ -57,7 +60,7 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name)
value
=
StripLeft
(
colon
);
value
=
StripLeft
(
colon
);
if
(
strcmp
(
line
,
"mtime"
)
==
0
)
if
(
strcmp
(
line
,
"mtime"
)
==
0
)
pm
.
mtime
=
st
rtol
(
value
,
nullptr
,
10
);
pm
.
mtime
=
st
d
::
chrono
::
system_clock
::
from_time_t
(
strtol
(
value
,
nullptr
,
10
)
);
else
else
throw
FormatRuntimeError
(
"unknown line in db: %s"
,
throw
FormatRuntimeError
(
"unknown line in db: %s"
,
line
);
line
);
...
...
src/PlaylistFile.cxx
View file @
6f37f575
...
@@ -148,7 +148,7 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
...
@@ -148,7 +148,7 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
return
false
;
return
false
;
info
.
name
=
std
::
move
(
name_utf8
);
info
.
name
=
std
::
move
(
name_utf8
);
info
.
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
fi
.
GetModificationTime
()
);
info
.
mtime
=
fi
.
GetModificationTime
(
);
return
true
;
return
true
;
}
}
...
...
src/command/OtherCommands.cxx
View file @
6f37f575
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include "decoder/DecoderPrint.hxx"
#include "decoder/DecoderPrint.hxx"
#include "ls.hxx"
#include "ls.hxx"
#include "mixer/Volume.hxx"
#include "mixer/Volume.hxx"
#include "util/ChronoUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/StringAPI.hxx"
#include "util/StringAPI.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/AllocatedPath.hxx"
...
@@ -63,7 +64,7 @@ print_spl_list(Response &r, const PlaylistVector &list)
...
@@ -63,7 +64,7 @@ print_spl_list(Response &r, const PlaylistVector &list)
for
(
const
auto
&
i
:
list
)
{
for
(
const
auto
&
i
:
list
)
{
r
.
Format
(
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
r
.
Format
(
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
if
(
i
.
mtime
>
0
)
if
(
!
IsNegative
(
i
.
mtime
)
)
time_print
(
r
,
"Last-Modified"
,
i
.
mtime
);
time_print
(
r
,
"Last-Modified"
,
i
.
mtime
);
}
}
}
}
...
...
src/command/PlaylistCommands.cxx
View file @
6f37f575
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "fs/AllocatedPath.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/UriUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ChronoUtil.hxx"
bool
bool
playlist_commands_available
()
noexcept
playlist_commands_available
()
noexcept
...
@@ -50,7 +51,7 @@ print_spl_list(Response &r, const PlaylistVector &list)
...
@@ -50,7 +51,7 @@ print_spl_list(Response &r, const PlaylistVector &list)
for
(
const
auto
&
i
:
list
)
{
for
(
const
auto
&
i
:
list
)
{
r
.
Format
(
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
r
.
Format
(
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
if
(
i
.
mtime
>
0
)
if
(
!
IsNegative
(
i
.
mtime
)
)
time_print
(
r
,
"Last-Modified"
,
i
.
mtime
);
time_print
(
r
,
"Last-Modified"
,
i
.
mtime
);
}
}
}
}
...
...
src/db/DatabasePrint.cxx
View file @
6f37f575
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "PlaylistInfo.hxx"
#include "PlaylistInfo.hxx"
#include "Interface.hxx"
#include "Interface.hxx"
#include "fs/Traits.hxx"
#include "fs/Traits.hxx"
#include "util/ChronoUtil.hxx"
#include <functional>
#include <functional>
...
@@ -134,7 +135,7 @@ PrintPlaylistFull(Response &r, bool base,
...
@@ -134,7 +135,7 @@ PrintPlaylistFull(Response &r, bool base,
print_playlist_in_directory
(
r
,
base
,
print_playlist_in_directory
(
r
,
base
,
&
directory
,
playlist
.
name
.
c_str
());
&
directory
,
playlist
.
name
.
c_str
());
if
(
playlist
.
mtime
>
0
)
if
(
!
IsNegative
(
playlist
.
mtime
)
)
time_print
(
r
,
"Last-Modified"
,
playlist
.
mtime
);
time_print
(
r
,
"Last-Modified"
,
playlist
.
mtime
);
}
}
...
...
src/db/PlaylistInfo.hxx
View file @
6f37f575
...
@@ -24,8 +24,7 @@
...
@@ -24,8 +24,7 @@
#include "Compiler.h"
#include "Compiler.h"
#include <string>
#include <string>
#include <chrono>
#include <sys/time.h>
/**
/**
* A directory entry pointing to a playlist file.
* A directory entry pointing to a playlist file.
...
@@ -36,7 +35,12 @@ struct PlaylistInfo {
...
@@ -36,7 +35,12 @@ struct PlaylistInfo {
*/
*/
std
::
string
name
;
std
::
string
name
;
time_t
mtime
;
/**
* The time stamp of the last file modification. A negative
* value means that this is unknown/unavailable.
*/
std
::
chrono
::
system_clock
::
time_point
mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
();
class
CompareName
{
class
CompareName
{
const
char
*
const
name
;
const
char
*
const
name
;
...
@@ -53,7 +57,8 @@ struct PlaylistInfo {
...
@@ -53,7 +57,8 @@ struct PlaylistInfo {
PlaylistInfo
()
=
default
;
PlaylistInfo
()
=
default
;
template
<
typename
N
>
template
<
typename
N
>
PlaylistInfo
(
N
&&
_name
,
time_t
_mtime
)
explicit
PlaylistInfo
(
N
&&
_name
,
std
::
chrono
::
system_clock
::
time_point
_mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
())
:
name
(
std
::
forward
<
N
>
(
_name
)),
mtime
(
_mtime
)
{}
:
name
(
std
::
forward
<
N
>
(
_name
)),
mtime
(
_mtime
)
{}
PlaylistInfo
(
const
PlaylistInfo
&
other
)
=
delete
;
PlaylistInfo
(
const
PlaylistInfo
&
other
)
=
delete
;
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
6f37f575
...
@@ -603,8 +603,12 @@ Visit(const struct mpd_playlist *playlist,
...
@@ -603,8 +603,12 @@ Visit(const struct mpd_playlist *playlist,
if
(
!
visit_playlist
)
if
(
!
visit_playlist
)
return
;
return
;
time_t
mtime
=
mpd_playlist_get_last_modified
(
playlist
);
PlaylistInfo
p
(
mpd_playlist_get_path
(
playlist
),
PlaylistInfo
p
(
mpd_playlist_get_path
(
playlist
),
mpd_playlist_get_last_modified
(
playlist
));
mtime
>
0
?
std
::
chrono
::
system_clock
::
from_time_t
(
mtime
)
:
std
::
chrono
::
system_clock
::
time_point
::
min
());
visit_playlist
(
p
,
LightDirectory
::
Root
());
visit_playlist
(
p
,
LightDirectory
::
Root
());
}
}
...
...
src/db/update/Walk.cxx
View file @
6f37f575
...
@@ -192,7 +192,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory,
...
@@ -192,7 +192,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory,
if
(
!
playlist_suffix_supported
(
suffix
))
if
(
!
playlist_suffix_supported
(
suffix
))
return
false
;
return
false
;
PlaylistInfo
pi
(
name
,
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
);
PlaylistInfo
pi
(
name
,
info
.
mtime
);
const
ScopeDatabaseLock
protect
;
const
ScopeDatabaseLock
protect
;
if
(
directory
.
playlists
.
UpdateOrInsert
(
std
::
move
(
pi
)))
if
(
directory
.
playlists
.
UpdateOrInsert
(
std
::
move
(
pi
)))
...
...
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