mpd/src/db/PlaylistInfo.hxx
Max Kellermann 7bb251dad8 db/update/Walk: use marker to remove deleted items
This eliminates all `Storage::GetInfo()` calls from
`UpdateWalk::PurgeDeletedFromDirectory()` and instead uses a "marker"
field to mark items that have been visited; later, all unmarked items
can be deleted.

This eliminates a lot of redundant I/O which is noticable with the
`curl` storage plugin (i.e. WebDAV).
2023-05-22 20:13:01 +02:00

58 lines
1.3 KiB
C++

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#ifndef MPD_PLAYLIST_INFO_HXX
#define MPD_PLAYLIST_INFO_HXX
#include <string>
#include <string_view>
#include <chrono>
/**
* A directory entry pointing to a playlist file.
*/
struct PlaylistInfo {
/**
* The UTF-8 encoded name of the playlist file.
*/
std::string name;
/**
* 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();
/**
* This field is used by the database update to check whether
* an item has disappeared.
*/
bool mark;
class CompareName {
const std::string_view name;
public:
constexpr CompareName(std::string_view _name) noexcept
:name(_name) {}
[[gnu::pure]]
bool operator()(const PlaylistInfo &pi) const noexcept {
return pi.name == name;
}
};
PlaylistInfo() = default;
template<typename N>
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;
PlaylistInfo(PlaylistInfo &&) = default;
};
#endif