Adding artist/release/track max name length checks. NOT TESTED

This commit is contained in:
emeric
2014-08-20 14:32:22 +02:00
parent 62d2f6af2a
commit 2f376fbc7a
5 changed files with 20 additions and 14 deletions
+5 -7
View File
@@ -21,11 +21,9 @@
- Implement a video database cleanup - Implement a video database cleanup
- Group video in "video groups". Each video may has sub groups (current "Path" class) - Group video in "video groups". Each video may has sub groups (current "Path" class)
-> Simplify database and remove the Path class -> Simplify database and remove the Path class
- Use size limits for strings (artist, release, genre)?
- Process only files whose extensions are well known in audio/video world (avoid useless parsing/errors)? - Process only files whose extensions are well known in audio/video world (avoid useless parsing/errors)?
[Metadata] [Metadata]
- Skip trailing non printable characters (spaces) in track name, artist, etc.
[Transcode] [Transcode]
- some zombies seem to be remaining after a week of use - some zombies seem to be remaining after a week of use
@@ -43,20 +41,20 @@
- Prefered codecs for audio/video? - Prefered codecs for audio/video?
[Audio] [Audio]
- Search patterns in the genre list
- ReleaseView/ArtistView/GenreView: <All> -> Track count for this special category. Easier: add a special entry '<All>' that contains everything? - ReleaseView/ArtistView/GenreView: <All> -> Track count for this special category. Easier: add a special entry '<All>' that contains everything?
- MediaPlayer: move slider using js (http://redmine.webtoolkit.eu/boards/2/topics/7924?r=8478) - MediaPlayer: move slider using js (http://redmine.webtoolkit.eu/boards/2/topics/7924?r=8478)
- TrackView : handle original release date - TrackView : handle original release date
- TrackView : handle duration > 1 hour - TrackView : handle duration > 1 hour
- TrackView : select only relevant columns to speed up queries (do not get eveything) - TrackView : select only relevant columns to speed up queries (do not get eveything)
- TrackView : Reselect the current selected item when displaying the updated search results - TrackView : Reselect the current selected item when displaying the updated search results
- ReleaseView: display the release's publication year - ReleaseView: display the original release's publication year
- OGG metadata -> properly handle metadata nested in the audio stream - OGG metadata -> properly handle metadata nested in the audio stream
- TrackView : when udating the view, reselect the current playing track
- Filters: use directly the id as constraint, instead of the name? - Filters: use directly the id as constraint, instead of the name?
- Implement a playlist: - Implement a playlist:
- Drag and drop all objets from the views (genre, artist, release, track) in the playlist? - Drag and drop all objets from the views (genre, artist, release, track) in the playlist?
- Add 'play/add last' button on mouse hover? - Add 'play/add last' button on mouse hover?
- Save/Load playlists? - Save/Load playlists?
[Video] [Video]
- View the Videos in a WtTableView ? - View the Videos in a WtTableView ?
+2 -2
View File
@@ -4,7 +4,7 @@ namespace Database
{ {
Artist::Artist(const std::string& name) Artist::Artist(const std::string& name)
: _name(name) : _name(std::string(name, 0 , _maxNameLength))
{ {
} }
@@ -12,7 +12,7 @@ Artist::Artist(const std::string& name)
Artist::pointer Artist::pointer
Artist::getByName(Wt::Dbo::Session& session, const std::string& name) Artist::getByName(Wt::Dbo::Session& session, const std::string& name)
{ {
return session.find<Artist>().where("name = ?").bind( name ); return session.find<Artist>().where("name = ?").bind( std::string(name, 0, _maxNameLength) );
} }
// Create // Create
+9 -1
View File
@@ -51,6 +51,9 @@ class Artist
private: private:
static const std::size_t _maxNameLength = 128;
std::string _name; std::string _name;
Wt::Dbo::collection< Wt::Dbo::ptr<Track> > _tracks; // Tracks of this artist Wt::Dbo::collection< Wt::Dbo::ptr<Track> > _tracks; // Tracks of this artist
@@ -93,6 +96,7 @@ class Release
} }
private: private:
static const std::size_t _maxNameLength = 128;
std::string _name; std::string _name;
Wt::Dbo::collection< Wt::Dbo::ptr<Track> > _tracks; // Tracks in the release Wt::Dbo::collection< Wt::Dbo::ptr<Track> > _tracks; // Tracks in the release
@@ -130,6 +134,7 @@ class Genre
} }
private: private:
static const std::size_t _maxNameLength = 128;
std::string _name; std::string _name;
Wt::Dbo::collection< Wt::Dbo::ptr<Track> > _tracks; Wt::Dbo::collection< Wt::Dbo::ptr<Track> > _tracks;
@@ -161,7 +166,7 @@ class Track
// Accessors // Accessors
void setTrackNumber(int num) { _trackNumber = num; } void setTrackNumber(int num) { _trackNumber = num; }
void setDiscNumber(int num) { _discNumber = num; } void setDiscNumber(int num) { _discNumber = num; }
void setName(const std::string& name) { _name = name; } void setName(const std::string& name) { _name = std::string(name, 0, _maxNameLength); }
void setDuration(boost::posix_time::time_duration duration) { _duration = duration; } void setDuration(boost::posix_time::time_duration duration) { _duration = duration; }
void setLastWriteTime(boost::posix_time::ptime time) { _fileLastWrite = time; } void setLastWriteTime(boost::posix_time::ptime time) { _fileLastWrite = time; }
void setChecksum(const std::vector<unsigned char>& checksum) { _fileChecksum = checksum; } void setChecksum(const std::vector<unsigned char>& checksum) { _fileChecksum = checksum; }
@@ -203,6 +208,9 @@ class Track
} }
private: private:
static const std::size_t _maxNameLength = 128;
int _trackNumber; int _trackNumber;
int _discNumber; int _discNumber;
std::string _name; std::string _name;
+2 -2
View File
@@ -7,7 +7,7 @@ Genre::Genre()
} }
Genre::Genre(const std::string& name) Genre::Genre(const std::string& name)
: _name( name ) : _name( std::string(name, 0, _maxNameLength) )
{ {
} }
@@ -16,7 +16,7 @@ Genre::pointer
Genre::getByName(Wt::Dbo::Session& session, const std::string& name) Genre::getByName(Wt::Dbo::Session& session, const std::string& name)
{ {
// TODO use like search // TODO use like search
return session.find<Genre>().where("name = ?").bind( name ); return session.find<Genre>().where("name = ?").bind( std::string(name, 0, _maxNameLength) );
} }
Genre::pointer Genre::pointer
+2 -2
View File
@@ -7,14 +7,14 @@
namespace Database { namespace Database {
Release::Release(const std::string& name) Release::Release(const std::string& name)
: _name(name) : _name(std::string(name, 0, _maxNameLength))
{ {
} }
Release::pointer Release::pointer
Release::getByName(Wt::Dbo::Session& session, const std::string& name) Release::getByName(Wt::Dbo::Session& session, const std::string& name)
{ {
return session.find<Release>().where("name = ?").bind( name ); return session.find<Release>().where("name = ?").bind( std::string(name, 0, _maxNameLength) );
} }
Release::pointer Release::pointer