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
ddc5602e
Commit
ddc5602e
authored
Apr 21, 2015
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
File: Add a lastModificationDate field
parent
5702e416
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
2 deletions
+24
-2
include/IFile.h
include/IFile.h
+1
-0
src/File.cpp
src/File.cpp
+11
-2
src/File.h
src/File.h
+2
-0
test/Files.cpp
test/Files.cpp
+10
-0
No files found.
include/IFile.h
View file @
ddc5602e
...
...
@@ -46,6 +46,7 @@ class IFile
/// part of a folder (false)
virtual
bool
isStandAlone
()
=
0
;
virtual
bool
isReady
()
const
=
0
;
virtual
unsigned
int
lastModificationDate
()
=
0
;
};
#endif // IFILE_H
src/File.cpp
View file @
ddc5602e
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include "Album.h"
#include "AlbumTrack.h"
...
...
@@ -29,6 +30,7 @@ File::File( DBConnection dbConnection, sqlite3_stmt* stmt )
m_mrl
=
(
const
char
*
)
sqlite3_column_text
(
stmt
,
6
);
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_isReady
=
m_type
!=
UnknownType
;
}
...
...
@@ -43,6 +45,7 @@ File::File( const std::string& mrl, unsigned int folderId )
,
m_mrl
(
mrl
)
,
m_movieId
(
0
)
,
m_folderId
(
folderId
)
,
m_lastModificationDate
(
time
(
nullptr
)
)
,
m_isReady
(
false
)
{
}
...
...
@@ -51,9 +54,9 @@ FilePtr File::create( DBConnection dbConnection, const std::string& mrl, unsigne
{
auto
self
=
std
::
make_shared
<
File
>
(
mrl
,
folderId
);
static
const
std
::
string
req
=
"INSERT INTO "
+
policy
::
FileTable
::
Name
+
"(mrl, folder_id) VALUES(?, ?)"
;
"(mrl, folder_id
, last_modification_date
) VALUES(?,
?,
?)"
;
if
(
_Cache
::
insert
(
dbConnection
,
self
,
req
,
mrl
,
sqlite
::
ForeignKey
(
folderId
)
)
==
false
)
if
(
_Cache
::
insert
(
dbConnection
,
self
,
req
,
mrl
,
sqlite
::
ForeignKey
(
folderId
)
,
self
->
m_lastModificationDate
)
==
false
)
return
nullptr
;
self
->
m_dbConnection
=
dbConnection
;
return
self
;
...
...
@@ -192,6 +195,11 @@ bool File::isStandAlone()
return
m_folderId
==
0
;
}
unsigned
int
File
::
lastModificationDate
()
{
return
m_lastModificationDate
;
}
bool
File
::
isReady
()
const
{
return
m_isReady
;
...
...
@@ -220,6 +228,7 @@ bool File::createTable( DBConnection connection )
"mrl TEXT UNIQUE ON CONFLICT FAIL,"
"movie_id UNSIGNED INTEGER,"
"folder_id UNSIGNED INTEGER,"
"last_modification_date UNSIGNED INTEGER,"
"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 @
ddc5602e
...
...
@@ -64,6 +64,7 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
virtual
bool
addAudioTrack
(
const
std
::
string
&
codec
,
unsigned
int
bitrate
,
unsigned
int
sampleRate
,
unsigned
int
nbChannels
);
virtual
std
::
vector
<
AudioTrackPtr
>
audioTracks
();
virtual
bool
isStandAlone
()
override
;
virtual
unsigned
int
lastModificationDate
()
override
;
virtual
bool
isReady
()
const
;
void
setReady
();
...
...
@@ -87,6 +88,7 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
AlbumTrackPtr
m_albumTrack
;
ShowEpisodePtr
m_showEpisode
;
MoviePtr
m_movie
;
unsigned
int
m_lastModificationDate
;
bool
m_isReady
;
...
...
test/Files.cpp
View file @
ddc5602e
...
...
@@ -83,3 +83,13 @@ TEST_F( Files, Duplicate )
f2
=
ml
->
file
(
"/dev/moulaf"
);
ASSERT_EQ
(
f
,
f2
);
}
TEST_F
(
Files
,
LastModificationDate
)
{
auto
f
=
ml
->
addFile
(
"/dev/seaotter"
);
ASSERT_NE
(
0u
,
f
->
lastModificationDate
()
);
SetUp
();
auto
f2
=
ml
->
file
(
"/dev/seaotter"
);
ASSERT_EQ
(
f
->
lastModificationDate
(),
f2
->
lastModificationDate
()
);
}
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