mirror of
https://github.com/QuasarApp/SoundBand.git
synced 2025-04-28 00:04:33 +00:00
Fix add music
This commit is contained in:
parent
a5d055f526
commit
532727b034
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user