Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
medialibrary
Commits
b15b8969
Commit
b15b8969
authored
May 18, 2014
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Index & make unique files mrls & labels values
parent
0bde9d01
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
src/File.cpp
src/File.cpp
+6
-2
src/Label.cpp
src/Label.cpp
+10
-1
src/SqliteTools.h
src/SqliteTools.h
+1
-1
No files found.
src/File.cpp
View file @
b15b8969
...
...
@@ -119,9 +119,13 @@ bool File::createTable(sqlite3* connection)
"album_track_id UNSIGNED INTEGER,"
"play_count UNSIGNED INTEGER,"
"show_episode_id UNSIGNED INTEGER,"
"mrl TEXT"
"mrl TEXT
UNIQUE ON CONFLICT FAIL
"
")"
;
return
SqliteTools
::
createTable
(
connection
,
req
.
c_str
()
);
if
(
SqliteTools
::
createTable
(
connection
,
req
.
c_str
()
)
==
false
)
return
false
;
req
=
"CREATE INDEX file_index ON "
+
policy
::
FileTable
::
Name
+
" (mrl)"
;
auto
stmt
=
SqliteTools
::
executeRequest
(
connection
,
req
.
c_str
()
);
return
sqlite3_step
(
stmt
.
get
()
)
==
SQLITE_DONE
;
}
bool
File
::
addLabel
(
LabelPtr
label
)
...
...
src/Label.cpp
View file @
b15b8969
...
...
@@ -73,10 +73,19 @@ bool Label::createTable(sqlite3* dbConnection)
{
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
LabelTable
::
Name
+
"("
"id_label INTEGER PRIMARY KEY AUTOINCREMENT, "
"name TEXT"
"name TEXT
UNIQUE ON CONFLICT FAIL
"
")"
;
if
(
SqliteTools
::
createTable
(
dbConnection
,
req
.
c_str
()
)
==
false
)
return
false
;
//FIXME: Check for a better way when addressing transactions
req
=
"CREATE INDEX label_index ON "
+
policy
::
LabelTable
::
Name
+
" (name)"
;
{
auto
stmt
=
SqliteTools
::
executeRequest
(
dbConnection
,
req
.
c_str
()
);
if
(
stmt
==
nullptr
)
return
false
;
if
(
sqlite3_step
(
stmt
.
get
()
)
!=
SQLITE_DONE
)
return
false
;
}
req
=
"CREATE TABLE IF NOT EXISTS LabelFileRelation("
"id_label INTEGER,"
"id_file INTEGER,"
...
...
src/SqliteTools.h
View file @
b15b8969
...
...
@@ -91,13 +91,13 @@ class SqliteTools
return
sqlite3_changes
(
dbConnection
)
>
0
;
}
private:
template
<
typename
...
Args
>
static
StmtPtr
executeRequest
(
sqlite3
*
dbConnection
,
const
char
*
req
,
const
Args
&
...
args
)
{
return
_executeRequest
<
1
>
(
dbConnection
,
req
,
args
...
);
}
private:
template
<
unsigned
int
>
static
StmtPtr
_executeRequest
(
sqlite3
*
dbConnection
,
const
char
*
req
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment