Some changes

This commit is contained in:
WolverinDEV 2020-03-20 00:56:36 +01:00
parent 0705c68b7b
commit e5f7b3bd32
4 changed files with 13 additions and 12 deletions

@ -1 +1 @@
Subproject commit cba03a6316db76fdf056a960ee509ad20542ea44
Subproject commit d9aa18444b8f1322862d8c74123ab6d72b270592

View File

@ -533,7 +533,7 @@ std::deque<std::unique_ptr<DatabaseHandler::GlobalVersionsStatistic>> DatabaseHa
bool DatabaseHandler::register_license_upgrade(license_key_id_t old_key_id, license_key_id_t new_key_id,
const std::chrono::system_clock::time_point &begin_timestamp, const std::chrono::system_clock::time_point &end_timestamp, const std::string &license_key) {
auto upgrade_id = std::chrono::system_clock::now().time_since_epoch().count();
auto upgrade_id = std::chrono::ceil<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
auto sql_result = sql::command(this->sql(), "INSERT INTO `license_upgrades` (`upgrade_id`, `old_key_id`, `new_key_id`, `timestamp_begin`, `timestamp_end`, `valid`, `use_count`, `license`) VALUES"
"(:upgrade_id, :old_key_id, :new_key_id, :timestamp_begin, :timestamp_end, 1, 0, :license)",
variable{":upgrade_id", upgrade_id},

2
music

@ -1 +1 @@
Subproject commit ad24c38923afe23d94452973337a416540e3c7aa
Subproject commit 8a896f7a797251b8104ba68559546e083da6518e

View File

@ -63,7 +63,8 @@ std::shared_ptr<ts::music::PlayableSong> PlayablePlaylist::current_song(bool& aw
if(this->properties()[property::PLAYLIST_CURRENT_SONG_ID].as<SongId>() != id) /* should not happen */
this->properties()[property::PLAYLIST_CURRENT_SONG_ID] = id;
if(!entry || entry->metadata.requires_load()) return nullptr;
if(!entry)
return nullptr;
if(entry->metadata.is_loading()) {
if(entry->metadata.load_begin + seconds(30) < system_clock::now()) {
@ -113,10 +114,10 @@ std::shared_ptr<PlaylistEntryInfo> PlayablePlaylist::playlist_next_entry() {
auto replay_mode = this->properties()[property::PLAYLIST_REPLAY_MODE].as<ReplayMode::value>();
unique_lock playlist_lock(this->playlist_lock);
auto current_song = this->playlist_find(playlist_lock, this->currently_playing());
auto old_song = this->playlist_find(playlist_lock, this->currently_playing());
if(replay_mode == ReplayMode::SINGLE_LOOPED) {
if(current_song) return current_song->entry;
if(old_song) return old_song->entry;
if(this->playlist_head) return this->playlist_head->entry;
this->properties()[property::PLAYLIST_FLAG_FINISHED] = true;
@ -125,9 +126,9 @@ std::shared_ptr<PlaylistEntryInfo> PlayablePlaylist::playlist_next_entry() {
std::shared_ptr<PlaylistEntryInfo> result;
if(replay_mode == ReplayMode::LINEAR || replay_mode == ReplayMode::LINEAR_LOOPED) {
if(current_song) {
if(current_song->next_song)
result = current_song->next_song->entry;
if(old_song) {
if(old_song->next_song)
result = old_song->next_song->entry;
else if(replay_mode == ReplayMode::LINEAR_LOOPED && this->playlist_head)
result = this->playlist_head->entry;
else {
@ -148,14 +149,14 @@ std::shared_ptr<PlaylistEntryInfo> PlayablePlaylist::playlist_next_entry() {
result = songs.front();
} else {
size_t index;
while(songs[index = (rand() % songs.size())] == (!current_song ? nullptr : current_song->entry)) { }
while(songs[index = (rand() % songs.size())] == (!old_song ? nullptr : old_song->entry)) { }
result = songs[index];
}
}
playlist_lock.unlock();
if(current_song && this->properties()[property::PLAYLIST_FLAG_DELETE_PLAYED].as<bool>()) {
this->delete_song(current_song->entry->song_id);
if(old_song && this->properties()[property::PLAYLIST_FLAG_DELETE_PLAYED].as<bool>()) {
this->delete_song(old_song->entry->song_id);
}
return result;
}