Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
8e6f99eb
Commit
8e6f99eb
authored
Sep 23, 2015
by
Hugo Beauzée-Luyssen
Browse files
File: Add snapshot()/setSnapshot methods
parent
b176f343
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/IFile.h
View file @
8e6f99eb
...
...
@@ -43,6 +43,10 @@ class IFile
virtual
bool
addAudioTrack
(
const
std
::
string
&
codec
,
unsigned
int
bitrate
,
unsigned
int
sampleRate
,
unsigned
int
nbChannels
)
=
0
;
virtual
std
::
vector
<
AudioTrackPtr
>
audioTracks
()
=
0
;
// Returns the location of this file snapshot.
// This is likely to be used for album arts as well.
virtual
const
std
::
string
&
snapshot
()
=
0
;
virtual
bool
setSnapshot
(
const
std
::
string
&
snapshot
)
=
0
;
/// Returns wether the file has been added as a stand alone file (true), or as
/// part of a folder (false)
virtual
bool
isStandAlone
()
=
0
;
...
...
src/File.cpp
View file @
8e6f99eb
...
...
@@ -32,6 +32,7 @@ File::File( DBConnection dbConnection, sqlite3_stmt* stmt )
m_movieId
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
7
);
m_folderId
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
8
);
m_lastModificationDate
=
sqlite
::
Traits
<
unsigned
int
>::
Load
(
stmt
,
9
);
m_snapshot
=
sqlite
::
Traits
<
std
::
string
>::
Load
(
stmt
,
10
);
m_isReady
=
m_type
!=
UnknownType
;
}
...
...
@@ -201,6 +202,21 @@ std::vector<AudioTrackPtr> File::audioTracks()
return
sqlite
::
Tools
::
fetchAll
<
AudioTrack
,
IAudioTrack
>
(
m_dbConnection
,
req
,
m_id
);
}
const
std
::
string
&
File
::
snapshot
()
{
return
m_snapshot
;
}
bool
File
::
setSnapshot
(
const
std
::
string
&
snapshot
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
FileTable
::
Name
+
" SET snapshot = ? WHERE id_file = ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
snapshot
,
m_id
)
==
false
)
return
false
;
m_snapshot
=
snapshot
;
return
true
;
}
bool
File
::
isStandAlone
()
{
return
m_folderId
==
0
;
...
...
@@ -240,6 +256,7 @@ bool File::createTable( DBConnection connection )
"movie_id UNSIGNED INTEGER,"
"folder_id UNSIGNED INTEGER,"
"last_modification_date UNSIGNED INTEGER,"
"snapshot TEXT,"
"FOREIGN KEY (album_track_id) REFERENCES "
+
policy
::
AlbumTrackTable
::
Name
+
"(id_track) ON DELETE CASCADE,"
"FOREIGN KEY (show_episode_id) REFERENCES "
+
policy
::
ShowEpisodeTable
::
Name
...
...
src/File.h
View file @
8e6f99eb
...
...
@@ -64,6 +64,9 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
virtual
std
::
vector
<
VideoTrackPtr
>
videoTracks
();
virtual
bool
addAudioTrack
(
const
std
::
string
&
codec
,
unsigned
int
bitrate
,
unsigned
int
sampleRate
,
unsigned
int
nbChannels
);
virtual
std
::
vector
<
AudioTrackPtr
>
audioTracks
();
virtual
const
std
::
string
&
snapshot
()
override
;
virtual
bool
setSnapshot
(
const
std
::
string
&
snapshot
)
override
;
virtual
bool
isStandAlone
()
override
;
virtual
unsigned
int
lastModificationDate
()
override
;
...
...
@@ -84,6 +87,7 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
unsigned
int
m_movieId
;
unsigned
int
m_folderId
;
unsigned
int
m_lastModificationDate
;
std
::
string
m_snapshot
;
// Auto fetched related properties
Album
*
m_album
;
...
...
test/Files.cpp
View file @
8e6f99eb
...
...
@@ -90,3 +90,19 @@ TEST_F( Files, Duration )
f
=
ml
->
file
(
"/some/file"
);
ASSERT_EQ
(
f
->
duration
(),
123u
);
}
TEST_F
(
Files
,
Snapshot
)
{
auto
f
=
ml
->
addFile
(
"/some/file"
);
ASSERT_EQ
(
f
->
snapshot
(),
""
);
std
::
string
newSnapshot
(
"/path/to/snapshot"
);
f
->
setSnapshot
(
newSnapshot
);
ASSERT_EQ
(
f
->
snapshot
(),
newSnapshot
);
Reload
();
f
=
ml
->
file
(
"/some/file"
);
ASSERT_EQ
(
f
->
snapshot
(),
newSnapshot
);
}
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