13 |
|
// XXX: implement |
14 |
|
} |
15 |
|
|
16 |
< |
MediaFolder::MediaFolder(_H<dbi::Connection>& connection, const api::Path& path, const api::Path& root) : connection(connection), path(path) |
16 |
> |
MediaFolder::MediaFolder(_H<dbi::Connection>& connection, const api::Path& path, const api::Path& root) : connection(connection), path(path), root(root) |
17 |
|
{ |
18 |
< |
_H<dbi::ResultSet> path_(connection->Parse(_B("SELECT path FROM folders WHERE path = ?"))->Execute(path.GetPath())); |
18 |
> |
_H<dbi::ResultSet> path_(connection->Parse(_B("SELECT path FROM folders WHERE path = ? AND root = ?"))->Execute(path.GetPath(), root.GetPath())); |
19 |
|
|
20 |
|
if (!path_->MoveNext()) |
21 |
+ |
{ |
22 |
+ |
connection->Parse(_B("DELETE FROM folders WHERE path = ?"))->Execute(path.GetPath()); |
23 |
+ |
|
24 |
|
if (path.GetPath() != root.GetPath()) |
25 |
|
connection->Parse(_B("INSERT INTO folders (path, folder, root) VALUES (?, ?, ?)"))->Execute(path.GetPath(), path.GetParent().GetPath(), root.GetPath()); |
26 |
|
else |
27 |
|
connection->Parse(_B("INSERT INTO folders (path, folder, root) VALUES (?, NULL, ?)"))->Execute(path.GetPath(), root.GetPath()); |
28 |
+ |
} |
29 |
|
} |
30 |
|
|
31 |
|
_L<MediaFile> MediaFolder::GetFiles() const |