10 |
|
|
11 |
|
#include "MediaFile.hpp" |
12 |
|
|
13 |
< |
MediaFile::MediaFile(const _R<dbi::Connection>& connection, const api::Path& path) : connection(connection), path(path) |
13 |
> |
MediaFile::MediaFile(const _R<Connector>& connector, const api::Path& path) : connector(connector), path(path) |
14 |
|
{ |
15 |
+ |
_R<dbi::Connection> connection(connector->Connect()); |
16 |
|
_R<dbi::ResultSet> info(connection->Parse(_B("SELECT artist, title, album, genre FROM files WHERE path = ?"))->Execute(path.GetPath())); |
17 |
|
|
18 |
|
if (info->MoveNext()) |
22 |
|
album = info->GetString(_B("album")); |
23 |
|
genre = info->GetString(_B("genre")); |
24 |
|
} |
25 |
+ |
|
26 |
+ |
connector->Release(connection); |
27 |
|
} |
28 |
|
|
29 |
< |
MediaFile::MediaFile(const _R<dbi::Connection>& connection, const api::Path& path, const cse::String& artist, const cse::String& title, const cse::String& album, const cse::String& genre, const api::Path& root) : connection(connection), path(path), artist(artist), title(title), album(album), genre(genre) |
29 |
> |
MediaFile::MediaFile(const _R<Connector>& connector, const api::Path& path, const cse::String& artist, const cse::String& title, const cse::String& album, const cse::String& genre, const api::Path& root) : connector(connector), path(path), artist(artist), title(title), album(album), genre(genre) |
30 |
|
{ |
31 |
+ |
_R<dbi::Connection> connection(connector->Connect()); |
32 |
|
_R<dbi::ResultSet> path_(connection->Parse(_B("SELECT path FROM files WHERE path = ?"))->Execute(path.GetPath())); |
33 |
|
|
34 |
|
if (path_->MoveNext()) |
51 |
|
} |
52 |
|
else |
53 |
|
connection->Parse(_B("INSERT INTO files (path, artist, title, album, genre, folder, root) VALUES (?, ?, ?, ?, ?, ?, ?)"))->Execute(path.GetPath(), artist, title, album, genre, path.GetParent().GetPath(), root.GetPath()); |
54 |
+ |
|
55 |
+ |
connector->Release(connection); |
56 |
|
} |