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 @@
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "util/StringStrip.hxx"
#include "util/ChronoUtil.hxx"
#include "util/RuntimeError.hxx"
#include <string.h>
...
...
@@ -31,17 +32,19 @@
void
playlist_vector_save
(
BufferedOutputStream
&
os
,
const
PlaylistVector
&
pv
)
{
for
(
const
PlaylistInfo
&
pi
:
pv
)
os
.
Format
(
PLAYLIST_META_BEGIN
"%s
\n
"
"mtime: %li
\n
"
"playlist_end
\n
"
,
pi
.
name
.
c_str
(),
(
long
)
pi
.
mtime
);
for
(
const
PlaylistInfo
&
pi
:
pv
)
{
os
.
Format
(
PLAYLIST_META_BEGIN
"%s
\n
"
,
pi
.
name
.
c_str
());
if
(
!
IsNegative
(
pi
.
mtime
))
os
.
Format
(
"mtime: %li
\n
"
,
(
long
)
std
::
chrono
::
system_clock
::
to_time_t
(
pi
.
mtime
));
os
.
Write
(
"playlist_end
\n
"
);
}
}
void
playlist_metadata_load
(
TextFile
&
file
,
PlaylistVector
&
pv
,
const
char
*
name
)
{
PlaylistInfo
pm
(
name
,
0
);
PlaylistInfo
pm
(
name
);
char
*
line
,
*
colon
;
const
char
*
value
;
...
...
@@ -57,7 +60,7 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name)
value
=
StripLeft
(
colon
);
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
throw
FormatRuntimeError
(
"unknown line in db: %s"
,
line
);
...
...
src/PlaylistFile.cxx
View file @
6f37f575
...
...
@@ -148,7 +148,7 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
return
false
;
info
.
name
=
std
::
move
(
name_utf8
);
info
.
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
fi
.
GetModificationTime
()
);
info
.
mtime
=
fi
.
GetModificationTime
(
);
return
true
;
}
...
...
src/command/OtherCommands.cxx
View file @
6f37f575
...
...
@@ -35,6 +35,7 @@
#include "decoder/DecoderPrint.hxx"
#include "ls.hxx"
#include "mixer/Volume.hxx"
#include "util/ChronoUtil.hxx"
#include "util/UriUtil.hxx"
#include "util/StringAPI.hxx"
#include "fs/AllocatedPath.hxx"
...
...
@@ -63,7 +64,7 @@ print_spl_list(Response &r, const PlaylistVector &list)
for
(
const
auto
&
i
:
list
)
{
r
.
Format
(
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
if
(
i
.
mtime
>
0
)
if
(
!
IsNegative
(
i
.
mtime
)
)
time_print
(
r
,
"Last-Modified"
,
i
.
mtime
);
}
}
...
...
src/command/PlaylistCommands.cxx
View file @
6f37f575
...
...
@@ -37,6 +37,7 @@
#include "fs/AllocatedPath.hxx"
#include "util/UriUtil.hxx"
#include "util/ConstBuffer.hxx"
#include "util/ChronoUtil.hxx"
bool
playlist_commands_available
()
noexcept
...
...
@@ -50,7 +51,7 @@ print_spl_list(Response &r, const PlaylistVector &list)
for
(
const
auto
&
i
:
list
)
{
r
.
Format
(
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
if
(
i
.
mtime
>
0
)
if
(
!
IsNegative
(
i
.
mtime
)
)
time_print
(
r
,
"Last-Modified"
,
i
.
mtime
);
}
}
...
...
src/db/DatabasePrint.cxx
View file @
6f37f575
...
...
@@ -34,6 +34,7 @@
#include "PlaylistInfo.hxx"
#include "Interface.hxx"
#include "fs/Traits.hxx"
#include "util/ChronoUtil.hxx"
#include <functional>
...
...
@@ -134,7 +135,7 @@ PrintPlaylistFull(Response &r, bool base,
print_playlist_in_directory
(
r
,
base
,
&
directory
,
playlist
.
name
.
c_str
());
if
(
playlist
.
mtime
>
0
)
if
(
!
IsNegative
(
playlist
.
mtime
)
)
time_print
(
r
,
"Last-Modified"
,
playlist
.
mtime
);
}
...
...
src/db/PlaylistInfo.hxx
View file @
6f37f575
...
...
@@ -24,8 +24,7 @@
#include "Compiler.h"
#include <string>
#include <sys/time.h>
#include <chrono>
/**
* A directory entry pointing to a playlist file.
...
...
@@ -36,7 +35,12 @@ struct PlaylistInfo {
*/
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
{
const
char
*
const
name
;
...
...
@@ -53,7 +57,8 @@ struct PlaylistInfo {
PlaylistInfo
()
=
default
;
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
)
{}
PlaylistInfo
(
const
PlaylistInfo
&
other
)
=
delete
;
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
6f37f575
...
...
@@ -603,8 +603,12 @@ Visit(const struct mpd_playlist *playlist,
if
(
!
visit_playlist
)
return
;
time_t
mtime
=
mpd_playlist_get_last_modified
(
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
());
}
...
...
src/db/update/Walk.cxx
View file @
6f37f575
...
...
@@ -192,7 +192,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory,
if
(
!
playlist_suffix_supported
(
suffix
))
return
false
;
PlaylistInfo
pi
(
name
,
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
);
PlaylistInfo
pi
(
name
,
info
.
mtime
);
const
ScopeDatabaseLock
protect
;
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