Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
902fbb33
Commit
902fbb33
authored
Feb 11, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/LightDirectory: use std::chrono::system_clock::time_point
parent
9f16c798
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
30 additions
and
18 deletions
+30
-18
DatabasePrint.cxx
src/db/DatabasePrint.cxx
+1
-1
LightDirectory.hxx
src/db/LightDirectory.hxx
+4
-3
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+6
-3
Directory.hxx
src/db/plugins/simple/Directory.hxx
+4
-1
DirectorySave.cxx
src/db/plugins/simple/DirectorySave.cxx
+6
-3
UpnpDatabasePlugin.cxx
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
+4
-2
Archive.cxx
src/db/update/Archive.cxx
+2
-2
Container.cxx
src/db/update/Container.cxx
+2
-2
Walk.cxx
src/db/update/Walk.cxx
+1
-1
No files found.
src/db/DatabasePrint.cxx
View file @
902fbb33
...
...
@@ -66,7 +66,7 @@ PrintDirectoryFull(Response &r, bool base, const LightDirectory &directory)
if
(
!
directory
.
IsRoot
())
{
PrintDirectoryURI
(
r
,
base
,
directory
);
if
(
directory
.
mtime
>
0
)
if
(
!
IsNegative
(
directory
.
mtime
)
)
time_print
(
r
,
"Last-Modified"
,
directory
.
mtime
);
}
}
...
...
src/db/LightDirectory.hxx
View file @
902fbb33
...
...
@@ -39,13 +39,14 @@ struct Tag;
struct
LightDirectory
{
const
char
*
uri
;
time_
t
mtime
;
std
::
chrono
::
system_clock
::
time_poin
t
mtime
;
constexpr
LightDirectory
(
const
char
*
_uri
,
time_t
_mtime
)
constexpr
LightDirectory
(
const
char
*
_uri
,
std
::
chrono
::
system_clock
::
time_point
_mtime
)
:
uri
(
_uri
),
mtime
(
_mtime
)
{}
static
constexpr
LightDirectory
Root
()
noexcept
{
return
LightDirectory
(
""
,
0
);
return
LightDirectory
(
""
,
std
::
chrono
::
system_clock
::
time_point
::
min
()
);
}
bool
IsRoot
()
const
noexcept
{
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
902fbb33
...
...
@@ -562,10 +562,13 @@ Visit(struct mpd_connection *connection,
VisitPlaylist
visit_playlist
)
{
const
char
*
path
=
mpd_directory_get_path
(
directory
);
std
::
chrono
::
system_clock
::
time_point
mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
();
#if LIBMPDCLIENT_CHECK_VERSION(2,9,0)
time_t
mtime
=
mpd_directory_get_last_modified
(
directory
);
#else
time_t
mtime
=
0
;
time_t
_
mtime
=
mpd_directory_get_last_modified
(
directory
);
if
(
_mtime
>
0
)
mtime
=
std
::
chrono
::
system_clock
::
from_time_t
(
_mtime
)
;
#endif
if
(
visit_directory
)
...
...
src/db/plugins/simple/Directory.hxx
View file @
902fbb33
...
...
@@ -85,7 +85,10 @@ struct Directory {
PlaylistVector
playlists
;
Directory
*
const
parent
;
time_t
mtime
=
0
;
std
::
chrono
::
system_clock
::
time_point
mtime
=
std
::
chrono
::
system_clock
::
time_point
::
min
();
uint64_t
inode
=
0
,
device
=
0
;
const
std
::
string
path
;
...
...
src/db/plugins/simple/DirectorySave.cxx
View file @
902fbb33
...
...
@@ -26,6 +26,7 @@
#include "PlaylistDatabase.hxx"
#include "fs/io/TextFile.hxx"
#include "fs/io/BufferedOutputStream.hxx"
#include "util/ChronoUtil.hxx"
#include "util/StringCompare.hxx"
#include "util/NumberParser.hxx"
#include "util/RuntimeError.hxx"
...
...
@@ -74,9 +75,9 @@ directory_save(BufferedOutputStream &os, const Directory &directory)
if
(
type
!=
nullptr
)
os
.
Format
(
DIRECTORY_TYPE
"%s
\n
"
,
type
);
if
(
directory
.
mtime
!=
0
)
if
(
!
IsNegative
(
directory
.
mtime
)
)
os
.
Format
(
DIRECTORY_MTIME
"%lu
\n
"
,
(
unsigned
long
)
directory
.
mtime
);
(
unsigned
long
)
std
::
chrono
::
system_clock
::
to_time_t
(
directory
.
mtime
)
);
os
.
Format
(
"%s%s
\n
"
,
DIRECTORY_BEGIN
,
directory
.
GetPath
());
}
...
...
@@ -102,7 +103,9 @@ ParseLine(Directory &directory, const char *line)
{
const
char
*
p
;
if
((
p
=
StringAfterPrefix
(
line
,
DIRECTORY_MTIME
)))
{
directory
.
mtime
=
ParseUint64
(
p
);
const
auto
mtime
=
ParseUint64
(
p
);
if
(
mtime
>
0
)
directory
.
mtime
=
std
::
chrono
::
system_clock
::
from_time_t
(
mtime
);
}
else
if
((
p
=
StringAfterPrefix
(
line
,
DIRECTORY_TYPE
)))
{
directory
.
device
=
ParseTypeString
(
p
);
}
else
...
...
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
View file @
902fbb33
...
...
@@ -477,7 +477,8 @@ VisitObject(const UPnPDirObject &object, const char *uri,
case
UPnPDirObject
:
:
Type
::
CONTAINER
:
if
(
visit_directory
)
visit_directory
(
LightDirectory
(
uri
,
0
));
visit_directory
(
LightDirectory
(
uri
,
std
::
chrono
::
system_clock
::
time_point
::
min
()));
break
;
case
UPnPDirObject
:
:
Type
::
ITEM
:
...
...
@@ -582,7 +583,8 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
if
(
vpath
.
empty
())
{
for
(
const
auto
&
server
:
discovery
->
GetDirectories
())
{
if
(
visit_directory
)
{
const
LightDirectory
d
(
server
.
getFriendlyName
(),
0
);
const
LightDirectory
d
(
server
.
getFriendlyName
(),
std
::
chrono
::
system_clock
::
time_point
::
min
());
visit_directory
(
d
);
}
...
...
src/db/update/Archive.cxx
View file @
902fbb33
...
...
@@ -137,7 +137,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
{
Directory
*
directory
=
LockFindChild
(
parent
,
name
);
if
(
directory
!=
nullptr
&&
directory
->
mtime
==
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
&&
if
(
directory
!=
nullptr
&&
directory
->
mtime
==
info
.
mtime
&&
!
walk_discard
)
/* MPD has already scanned the archive, and it hasn't
changed since - don't consider updating it */
...
...
@@ -173,7 +173,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
directory
->
device
=
DEVICE_INARCHIVE
;
}
directory
->
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
;
directory
->
mtime
=
info
.
mtime
;
UpdateArchiveVisitor
visitor
(
*
this
,
*
file
,
directory
);
file
->
Visit
(
visitor
);
...
...
src/db/update/Container.cxx
View file @
902fbb33
...
...
@@ -43,7 +43,7 @@ UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name,
if
(
directory
->
IsMount
())
return
nullptr
;
if
(
directory
->
mtime
==
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
&&
!
walk_discard
)
{
if
(
directory
->
mtime
==
info
.
mtime
&&
!
walk_discard
)
{
/* not modified */
return
nullptr
;
}
...
...
@@ -53,7 +53,7 @@ UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name,
}
directory
=
parent
.
MakeChild
(
name
);
directory
->
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
;
directory
->
mtime
=
info
.
mtime
;
return
directory
;
}
...
...
src/db/update/Walk.cxx
View file @
902fbb33
...
...
@@ -382,7 +382,7 @@ UpdateWalk::UpdateDirectory(Directory &directory,
UpdateDirectoryChild
(
directory
,
child_exclude_list
,
name_utf8
,
info2
);
}
directory
.
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
;
directory
.
mtime
=
info
.
mtime
;
return
true
;
}
...
...
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