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
903410bf
Commit
903410bf
authored
Nov 17, 2015
by
Hugo Beauzée-Luyssen
Browse files
Media: Provide an insertion date
parent
d9664e4d
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/IMedia.h
View file @
903410bf
...
...
@@ -65,6 +65,7 @@ class IMedia
// 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
unsigned
int
insertionDate
()
const
=
0
;
};
#endif // IFILE_H
src/Media.cpp
View file @
903410bf
...
...
@@ -57,6 +57,7 @@ Media::Media( DBConnection dbConnection, sqlite::Row& row )
>>
m_movieId
>>
m_folderId
>>
m_lastModificationDate
>>
m_insertionDate
>>
m_snapshot
>>
m_isParsed
>>
m_title
;
...
...
@@ -72,6 +73,7 @@ Media::Media( const fs::IFile* file, unsigned int folderId, const std::string& t
,
m_movieId
(
0
)
,
m_folderId
(
folderId
)
,
m_lastModificationDate
(
file
->
lastModificationDate
()
)
,
m_insertionDate
(
time
(
nullptr
)
)
,
m_isParsed
(
false
)
,
m_title
(
title
)
,
m_changed
(
false
)
...
...
@@ -82,10 +84,10 @@ std::shared_ptr<Media> Media::create( DBConnection dbConnection, Type type, cons
{
auto
self
=
std
::
make_shared
<
Media
>
(
file
,
folderId
,
file
->
name
(),
type
);
static
const
std
::
string
req
=
"INSERT INTO "
+
policy
::
MediaTable
::
Name
+
"(type, mrl, folder_id, last_modification_date, title) VALUES(?, ?, ?, ?, ?)"
;
"(type, mrl, folder_id, last_modification_date,
insertion_date,
title) VALUES(?, ?, ?, ?,
?,
?)"
;
if
(
insert
(
dbConnection
,
self
,
req
,
type
,
self
->
m_mrl
,
sqlite
::
ForeignKey
(
folderId
),
self
->
m_lastModificationDate
,
self
->
m_title
)
==
false
)
self
->
m_lastModificationDate
,
self
->
m_insertionDate
,
self
->
m_title
)
==
false
)
return
nullptr
;
self
->
m_dbConnection
=
dbConnection
;
return
self
;
...
...
@@ -225,6 +227,11 @@ const std::string &Media::snapshot()
return
m_snapshot
;
}
unsigned
int
Media
::
insertionDate
()
const
{
return
m_insertionDate
;
}
void
Media
::
setSnapshot
(
const
std
::
string
&
snapshot
)
{
if
(
m_snapshot
==
snapshot
)
...
...
@@ -319,6 +326,7 @@ bool Media::createTable( DBConnection connection )
"movie_id UNSIGNED INTEGER,"
"folder_id UNSIGNED INTEGER,"
"last_modification_date UNSIGNED INTEGER,"
"insertion_date UNSIGNED INTEGER,"
"snapshot TEXT,"
"parsed BOOLEAN NOT NULL DEFAULT 0,"
"title TEXT,"
...
...
src/Media.h
View file @
903410bf
...
...
@@ -92,6 +92,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
unsigned
int
nbChannels
,
const
std
::
string
&
language
,
const
std
::
string
&
desc
);
virtual
std
::
vector
<
AudioTrackPtr
>
audioTracks
()
override
;
virtual
const
std
::
string
&
snapshot
()
override
;
virtual
unsigned
int
insertionDate
()
const
override
;
void
setSnapshot
(
const
std
::
string
&
snapshot
);
bool
save
();
...
...
@@ -118,6 +119,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
unsigned
int
m_movieId
;
unsigned
int
m_folderId
;
unsigned
int
m_lastModificationDate
;
unsigned
int
m_insertionDate
;
std
::
string
m_snapshot
;
bool
m_isParsed
;
std
::
string
m_title
;
...
...
test/unittest/MediaTests.cpp
View file @
903410bf
...
...
@@ -49,6 +49,7 @@ TEST_F( Medias, Create )
ASSERT_TRUE
(
f
->
isStandAlone
()
);
ASSERT_FALSE
(
f
->
isParsed
()
);
ASSERT_EQ
(
f
->
duration
(),
-
1
);
ASSERT_NE
(
0u
,
f
->
insertionDate
()
);
auto
files
=
ml
->
files
();
ASSERT_EQ
(
files
.
size
(),
1u
);
...
...
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