Fix add music

This commit is contained in:
usermeme 2017-12-25 19:23:24 +03:00
parent a5d055f526
commit 532727b034
2 changed files with 11 additions and 3 deletions

View File

@ -166,6 +166,10 @@ int MySql::save(const QString &url){
song.size = bytes.size();
song.source = bytes;
if(!song.isValid()){
return -1;
}
return save(song);
}

View File

@ -1,7 +1,8 @@
#include "song.h"
#include <QStringList>
namespace syncLib{
static const QStringList ValidSongs = {".mp3", ".wav", ".ogg"};
SongHeader::SongHeader()
{
this->id = -1;
@ -28,8 +29,11 @@ unsigned int SongHeader::getSize() const{
}
bool SongHeader::isValid() const{
return id > -1 && !name.isEmpty() && size > 0 && name.endsWith(".mp3");
bool CheckSongs = false;
for (QString i: ValidSongs){
CheckSongs = CheckSongs || name.endsWith(i);
}
return id > -1 && !name.isEmpty() && size > 0 && CheckSongs;
}