db/PlaylistInfo: use std::chrono::system_clock::time_point
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user