Add "added" timestamp to song database
- added is set to current time, if a new song is added to the database. - GetAdded falls back to mtime. Code for proxy plugin is missing, this needs a patch for libmpdclient. closes #378
This commit is contained in:
@@ -60,6 +60,13 @@ DatabaseVisitorHelper::Commit()
|
||||
? a.GetLastModified() > b.GetLastModified()
|
||||
: a.GetLastModified() < b.GetLastModified();
|
||||
});
|
||||
else if (sort == TagType(SORT_TAG_ADDED))
|
||||
std::stable_sort(songs.begin(), songs.end(),
|
||||
[descending](const DetachedSong &a, const DetachedSong &b){
|
||||
return descending
|
||||
? a.GetAdded() > b.GetAdded()
|
||||
: a.GetAdded() < b.GetAdded();
|
||||
});
|
||||
else
|
||||
std::stable_sort(songs.begin(), songs.end(),
|
||||
[sort, descending](const DetachedSong &a,
|
||||
|
||||
@@ -19,6 +19,7 @@ Song::Song(DetachedSong &&other, Directory &_parent) noexcept
|
||||
filename(other.GetURI()),
|
||||
tag(std::move(other.WritableTag())),
|
||||
mtime(other.GetLastModified()),
|
||||
added(other.GetAdded()),
|
||||
start_time(other.GetStartTime()),
|
||||
end_time(other.GetEndTime()),
|
||||
audio_format(other.GetAudioFormat())
|
||||
@@ -117,6 +118,9 @@ Song::Export() const noexcept
|
||||
dest.mtime = IsNegative(mtime) && target_song != nullptr
|
||||
? target_song->mtime
|
||||
: mtime;
|
||||
dest.added = IsNegative(added) && target_song != nullptr
|
||||
? target_song->added
|
||||
: added;
|
||||
dest.start_time = start_time.IsZero() && target_song != nullptr
|
||||
? target_song->start_time
|
||||
: start_time;
|
||||
|
||||
@@ -56,6 +56,13 @@ struct Song : IntrusiveListHook<> {
|
||||
std::chrono::system_clock::time_point mtime =
|
||||
std::chrono::system_clock::time_point::min();
|
||||
|
||||
/**
|
||||
* The time stamp when the file was added. A negative
|
||||
* value means that this is unknown/unavailable.
|
||||
*/
|
||||
std::chrono::system_clock::time_point added =
|
||||
std::chrono::system_clock::time_point::min();
|
||||
|
||||
/**
|
||||
* Start of this sub-song within the file.
|
||||
*/
|
||||
|
||||
@@ -50,6 +50,7 @@ try {
|
||||
}
|
||||
|
||||
new_song->mark = true;
|
||||
new_song->added = std::chrono::system_clock::now();
|
||||
|
||||
{
|
||||
const ScopeDatabaseLock protect;
|
||||
|
||||
Reference in New Issue
Block a user