Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
5c50dd86
Commit
5c50dd86
authored
Feb 23, 2018
by
Hugo Beauzée-Luyssen
Browse files
Folder: Split triggers & indices creation in a specific method
parent
616c6ea1
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Folder.cpp
View file @
5c50dd86
...
...
@@ -93,6 +93,13 @@ void Folder::createTable( sqlite::Connection* connection)
"(id_folder) ON DELETE CASCADE,"
"UNIQUE(folder_id) ON CONFLICT FAIL"
")"
;
sqlite
::
Tools
::
executeRequest
(
connection
,
req
);
sqlite
::
Tools
::
executeRequest
(
connection
,
exclEntryReq
);
}
void
Folder
::
createTriggers
(
sqlite
::
Connection
*
connection
)
{
std
::
string
triggerReq
=
"CREATE TRIGGER IF NOT EXISTS is_device_present AFTER UPDATE OF is_present ON "
+
policy
::
DeviceTable
::
Name
+
" WHEN old.is_present != new.is_present"
...
...
@@ -103,8 +110,7 @@ void Folder::createTable( sqlite::Connection* connection)
policy
::
FolderTable
::
Name
+
" (device_id)"
;
std
::
string
parentFolderIndexReq
=
"CREATE INDEX IF NOT EXISTS parent_folder_id_idx ON "
+
policy
::
FolderTable
::
Name
+
" (parent_id)"
;
sqlite
::
Tools
::
executeRequest
(
connection
,
req
);
sqlite
::
Tools
::
executeRequest
(
connection
,
exclEntryReq
);
sqlite
::
Tools
::
executeRequest
(
connection
,
triggerReq
);
sqlite
::
Tools
::
executeRequest
(
connection
,
deviceIndexReq
);
sqlite
::
Tools
::
executeRequest
(
connection
,
parentFolderIndexReq
);
...
...
src/Folder.h
View file @
5c50dd86
...
...
@@ -61,6 +61,7 @@ public:
Folder
(
MediaLibraryPtr
ml
,
const
std
::
string
&
path
,
int64_t
parent
,
int64_t
deviceId
,
bool
isRemovable
);
static
void
createTable
(
sqlite
::
Connection
*
connection
);
static
void
createTriggers
(
sqlite
::
Connection
*
connection
);
static
std
::
shared_ptr
<
Folder
>
create
(
MediaLibraryPtr
ml
,
const
std
::
string
&
mrl
,
int64_t
parentId
,
Device
&
device
,
fs
::
IDevice
&
deviceFs
);
static
void
excludeEntryFolder
(
MediaLibraryPtr
ml
,
int64_t
folderId
);
static
bool
blacklist
(
MediaLibraryPtr
ml
,
const
std
::
string
&
mrl
);
...
...
src/MediaLibrary.cpp
View file @
5c50dd86
...
...
@@ -162,6 +162,7 @@ void MediaLibrary::createAllTables()
void
MediaLibrary
::
createAllTriggers
()
{
auto
dbModelVersion
=
m_settings
.
dbModelVersion
();
Folder
::
createTriggers
(
m_dbConnection
.
get
()
);
Album
::
createTriggers
(
m_dbConnection
.
get
()
);
AlbumTrack
::
createTriggers
(
m_dbConnection
.
get
()
);
Artist
::
createTriggers
(
m_dbConnection
.
get
(),
dbModelVersion
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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