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
3fc4da38
Commit
3fc4da38
authored
May 21, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple/Song: allow LoadFile(), UpdateFile() to throw
Preparing to move logger calls out of lower-level libaries, and propagating error details to the caller instead.
parent
6ee7d88a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
SongUpdate.cxx
src/SongUpdate.cxx
+3
-10
Song.hxx
src/db/plugins/simple/Song.hxx
+12
-2
UpdateSong.cxx
src/db/update/UpdateSong.cxx
+6
-1
No files found.
src/SongUpdate.cxx
View file @
3fc4da38
...
...
@@ -42,8 +42,7 @@
#ifdef ENABLE_DATABASE
SongPtr
Song
::
LoadFile
(
Storage
&
storage
,
const
char
*
path_utf8
,
Directory
&
parent
)
noexcept
Song
::
LoadFile
(
Storage
&
storage
,
const
char
*
path_utf8
,
Directory
&
parent
)
{
assert
(
!
uri_has_scheme
(
path_utf8
));
assert
(
strchr
(
path_utf8
,
'\n'
)
==
nullptr
);
...
...
@@ -60,17 +59,11 @@ Song::LoadFile(Storage &storage, const char *path_utf8,
#ifdef ENABLE_DATABASE
bool
Song
::
UpdateFile
(
Storage
&
storage
)
noexcept
Song
::
UpdateFile
(
Storage
&
storage
)
{
const
auto
&
relative_uri
=
GetURI
();
StorageFileInfo
info
;
try
{
info
=
storage
.
GetInfo
(
relative_uri
.
c_str
(),
true
);
}
catch
(...)
{
return
false
;
}
const
auto
info
=
storage
.
GetInfo
(
relative_uri
.
c_str
(),
true
);
if
(
!
info
.
IsRegular
())
return
false
;
...
...
src/db/plugins/simple/Song.hxx
View file @
3fc4da38
...
...
@@ -105,13 +105,23 @@ struct Song {
* allocate a new song structure with a local file name and attempt to
* load its metadata. If all decoder plugin fail to read its meta
* data, nullptr is returned.
*
* Throws on error.
*
* @return the song on success, nullptr if the file was not
* recognized
*/
static
SongPtr
LoadFile
(
Storage
&
storage
,
const
char
*
name_utf8
,
Directory
&
parent
)
noexcept
;
Directory
&
parent
);
void
Free
()
noexcept
;
bool
UpdateFile
(
Storage
&
storage
)
noexcept
;
/**
* Throws on error.
*
* @return true on success, false if the file was not recognized
*/
bool
UpdateFile
(
Storage
&
storage
);
#ifdef ENABLE_ARCHIVE
static
SongPtr
LoadFromArchive
(
ArchiveFile
&
archive
,
...
...
src/db/update/UpdateSong.cxx
View file @
3fc4da38
...
...
@@ -33,7 +33,7 @@ inline void
UpdateWalk
::
UpdateSongFile2
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
const
StorageFileInfo
&
info
)
noexcept
{
try
{
Song
*
song
;
{
const
ScopeDatabaseLock
protect
;
...
...
@@ -61,6 +61,7 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
if
(
song
==
nullptr
)
{
FormatDebug
(
update_domain
,
"reading %s/%s"
,
directory
.
GetPath
(),
name
);
auto
new_song
=
Song
::
LoadFile
(
storage
,
name
,
directory
);
if
(
!
new_song
)
{
FormatDebug
(
update_domain
,
...
...
@@ -89,6 +90,10 @@ UpdateWalk::UpdateSongFile2(Directory &directory,
modified
=
true
;
}
}
catch
(...)
{
FormatError
(
std
::
current_exception
(),
"error reading file %s/%s"
,
directory
.
GetPath
(),
name
);
}
bool
...
...
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