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
6636c69a
Commit
6636c69a
authored
Feb 11, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/FileInfo: convert mtime to std::chrono::system_clock::time_point
parent
0ccaf4a1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
29 additions
and
27 deletions
+29
-27
SongUpdate.cxx
src/SongUpdate.cxx
+1
-1
StorageCommands.cxx
src/command/StorageCommands.cxx
+2
-1
Archive.cxx
src/db/update/Archive.cxx
+2
-2
Container.cxx
src/db/update/Container.cxx
+3
-3
UpdateSong.cxx
src/db/update/UpdateSong.cxx
+3
-2
Walk.cxx
src/db/update/Walk.cxx
+2
-2
FileInfo.hxx
src/storage/FileInfo.hxx
+6
-4
CurlStorage.cxx
src/storage/plugins/CurlStorage.cxx
+2
-6
LocalStorage.cxx
src/storage/plugins/LocalStorage.cxx
+1
-1
NfsStorage.cxx
src/storage/plugins/NfsStorage.cxx
+2
-2
SmbclientStorage.cxx
src/storage/plugins/SmbclientStorage.cxx
+1
-1
run_storage.cxx
test/run_storage.cxx
+4
-2
No files found.
src/SongUpdate.cxx
View file @
6636c69a
...
...
@@ -88,7 +88,7 @@ Song::UpdateFile(Storage &storage)
return
false
;
}
mtime
=
info
.
mtime
;
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
;
tag_builder
.
Commit
(
tag
);
return
true
;
}
...
...
src/command/StorageCommands.cxx
View file @
6636c69a
...
...
@@ -24,6 +24,7 @@
#include "Request.hxx"
#include "CommandError.hxx"
#include "util/UriUtil.hxx"
#include "util/ChronoUtil.hxx"
#include "util/ConstBuffer.hxx"
#include "fs/Traits.hxx"
#include "client/Client.hxx"
...
...
@@ -88,7 +89,7 @@ handle_listfiles_storage(Response &r, StorageDirectoryReader &reader)
break
;
}
if
(
info
.
mtime
!=
0
)
if
(
!
IsNegative
(
info
.
mtime
)
)
time_print
(
r
,
"Last-Modified"
,
info
.
mtime
);
}
}
...
...
src/db/update/Archive.cxx
View file @
6636c69a
...
...
@@ -137,7 +137,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
{
Directory
*
directory
=
LockFindChild
(
parent
,
name
);
if
(
directory
!=
nullptr
&&
directory
->
mtime
==
info
.
mtime
&&
if
(
directory
!=
nullptr
&&
directory
->
mtime
==
std
::
chrono
::
system_clock
::
to_time_t
(
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
=
info
.
mtime
;
directory
->
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
;
UpdateArchiveVisitor
visitor
(
*
this
,
*
file
,
directory
);
file
->
Visit
(
visitor
);
...
...
src/db/update/Container.cxx
View file @
6636c69a
...
...
@@ -43,7 +43,7 @@ UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name,
if
(
directory
->
IsMount
())
return
nullptr
;
if
(
directory
->
mtime
==
info
.
mtime
&&
!
walk_discard
)
{
if
(
directory
->
mtime
==
std
::
chrono
::
system_clock
::
to_time_t
(
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
=
info
.
mtime
;
directory
->
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
;
return
directory
;
}
...
...
@@ -107,7 +107,7 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
*
contdir
);
// shouldn't be necessary but it's there..
song
->
mtime
=
info
.
mtime
;
song
->
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
;
FormatDefault
(
update_domain
,
"added %s/%s"
,
contdir
->
GetPath
(),
song
->
uri
);
...
...
src/db/update/UpdateSong.cxx
View file @
6636c69a
...
...
@@ -51,7 +51,8 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
return
;
}
if
(
!
(
song
!=
nullptr
&&
info
.
mtime
==
song
->
mtime
&&
if
(
!
(
song
!=
nullptr
&&
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
==
song
->
mtime
&&
!
walk_discard
)
&&
UpdateContainerFile
(
directory
,
name
,
suffix
,
info
))
{
if
(
song
!=
nullptr
)
...
...
@@ -79,7 +80,7 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
modified
=
true
;
FormatDefault
(
update_domain
,
"added %s/%s"
,
directory
.
GetPath
(),
name
);
}
else
if
(
info
.
mtime
!=
song
->
mtime
||
walk_discard
)
{
}
else
if
(
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
!=
song
->
mtime
||
walk_discard
)
{
FormatDefault
(
update_domain
,
"updating %s/%s"
,
directory
.
GetPath
(),
name
);
if
(
!
song
->
UpdateFile
(
storage
))
{
...
...
src/db/update/Walk.cxx
View file @
6636c69a
...
...
@@ -192,7 +192,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory,
if
(
!
playlist_suffix_supported
(
suffix
))
return
false
;
PlaylistInfo
pi
(
name
,
info
.
mtime
);
PlaylistInfo
pi
(
name
,
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
);
const
ScopeDatabaseLock
protect
;
if
(
directory
.
playlists
.
UpdateOrInsert
(
std
::
move
(
pi
)))
...
...
@@ -382,7 +382,7 @@ UpdateWalk::UpdateDirectory(Directory &directory,
UpdateDirectoryChild
(
directory
,
child_exclude_list
,
name_utf8
,
info2
);
}
directory
.
mtime
=
info
.
mtime
;
directory
.
mtime
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
)
;
return
true
;
}
...
...
src/storage/FileInfo.hxx
View file @
6636c69a
...
...
@@ -22,7 +22,8 @@
#include "check.h"
#include <time.h>
#include <chrono>
#include <stdint.h>
struct
StorageFileInfo
{
...
...
@@ -40,9 +41,10 @@ struct StorageFileInfo {
uint64_t
size
;
/**
* The modification time. 0 means unknown / not applicable.
* The modification time. A negative value means unknown /
* not applicable.
*/
time_
t
mtime
;
std
::
chrono
::
system_clock
::
time_poin
t
mtime
;
/**
* Device id and inode number. 0 means unknown / not
...
...
@@ -55,7 +57,7 @@ struct StorageFileInfo {
explicit
constexpr
StorageFileInfo
(
Type
_type
)
:
type
(
_type
),
size
(
0
),
mtime
(
0
),
mtime
(
std
::
chrono
::
system_clock
::
time_point
::
min
()
),
device
(
0
),
inode
(
0
)
{}
constexpr
bool
IsRegular
()
const
{
...
...
src/storage/plugins/CurlStorage.cxx
View file @
6636c69a
...
...
@@ -418,9 +418,7 @@ protected:
?
StorageFileInfo
::
Type
::
DIRECTORY
:
StorageFileInfo
::
Type
::
REGULAR
;
info
.
size
=
r
.
length
;
info
.
mtime
=
!
IsNegative
(
r
.
mtime
)
?
std
::
chrono
::
system_clock
::
to_time_t
(
r
.
mtime
)
:
0
;
info
.
mtime
=
r
.
mtime
;
}
};
...
...
@@ -514,9 +512,7 @@ protected:
?
StorageFileInfo
::
Type
::
DIRECTORY
:
StorageFileInfo
::
Type
::
REGULAR
);
info
.
size
=
r
.
length
;
info
.
mtime
=
!
IsNegative
(
r
.
mtime
)
?
std
::
chrono
::
system_clock
::
to_time_t
(
r
.
mtime
)
:
0
;
info
.
mtime
=
r
.
mtime
;
}
};
...
...
src/storage/plugins/LocalStorage.cxx
View file @
6636c69a
...
...
@@ -86,7 +86,7 @@ Stat(Path path, bool follow)
info
.
type
=
StorageFileInfo
::
Type
::
OTHER
;
info
.
size
=
src
.
GetSize
();
info
.
mtime
=
s
td
::
chrono
::
system_clock
::
to_time_t
(
src
.
GetModificationTime
()
);
info
.
mtime
=
s
rc
.
GetModificationTime
(
);
#ifdef WIN32
info
.
device
=
info
.
inode
=
0
;
#else
...
...
src/storage/plugins/NfsStorage.cxx
View file @
6636c69a
...
...
@@ -250,7 +250,7 @@ Copy(StorageFileInfo &info, const struct stat &st)
info
.
type
=
StorageFileInfo
::
Type
::
OTHER
;
info
.
size
=
st
.
st_size
;
info
.
mtime
=
st
.
st_mtime
;
info
.
mtime
=
st
d
::
chrono
::
system_clock
::
from_time_t
(
st
.
st_mtime
)
;
info
.
device
=
st
.
st_dev
;
info
.
inode
=
st
.
st_ino
;
}
...
...
@@ -316,7 +316,7 @@ Copy(StorageFileInfo &info, const struct nfsdirent &ent)
}
info
.
size
=
ent
.
size
;
info
.
mtime
=
ent
.
mtime
.
tv_sec
;
info
.
mtime
=
std
::
chrono
::
system_clock
::
from_time_t
(
ent
.
mtime
.
tv_sec
)
;
info
.
device
=
0
;
info
.
inode
=
ent
.
inode
;
}
...
...
src/storage/plugins/SmbclientStorage.cxx
View file @
6636c69a
...
...
@@ -111,7 +111,7 @@ GetInfo(const char *path)
info
.
type
=
StorageFileInfo
::
Type
::
OTHER
;
info
.
size
=
st
.
st_size
;
info
.
mtime
=
st
.
st_mtime
;
info
.
mtime
=
st
d
::
chrono
::
system_clock
::
from_time_t
(
st
.
st_mtime
)
;
info
.
device
=
st
.
st_dev
;
info
.
inode
=
st
.
st_ino
;
return
info
;
...
...
test/run_storage.cxx
View file @
6636c69a
...
...
@@ -23,6 +23,7 @@
#include "storage/Registry.hxx"
#include "storage/StorageInterface.hxx"
#include "storage/FileInfo.hxx"
#include "util/ChronoUtil.hxx"
#include <memory>
#include <stdexcept>
...
...
@@ -69,9 +70,10 @@ Ls(Storage &storage, const char *path)
char
mtime_buffer
[
32
];
const
char
*
mtime
=
" "
;
if
(
info
.
mtime
>
0
)
{
if
(
!
IsNegative
(
info
.
mtime
))
{
time_t
t
=
std
::
chrono
::
system_clock
::
to_time_t
(
info
.
mtime
);
strftime
(
mtime_buffer
,
sizeof
(
mtime_buffer
),
"%F"
,
gmtime
(
&
info
.
mtime
));
gmtime
(
&
t
));
mtime
=
mtime_buffer
;
}
...
...
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