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
100308db
Commit
100308db
authored
Sep 16, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/update: catch exceptions from Storage plugins
parent
ab967462
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
10 deletions
+41
-10
SongUpdate.cxx
src/SongUpdate.cxx
+8
-1
UpdateIO.cxx
src/db/update/UpdateIO.cxx
+19
-4
Walk.cxx
src/db/update/Walk.cxx
+14
-5
No files found.
src/SongUpdate.cxx
View file @
100308db
...
@@ -35,6 +35,8 @@
...
@@ -35,6 +35,8 @@
#include "TagArchive.hxx"
#include "TagArchive.hxx"
#endif
#endif
#include <stdexcept>
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
...
@@ -65,8 +67,13 @@ Song::UpdateFile(Storage &storage)
...
@@ -65,8 +67,13 @@ Song::UpdateFile(Storage &storage)
const
auto
&
relative_uri
=
GetURI
();
const
auto
&
relative_uri
=
GetURI
();
StorageFileInfo
info
;
StorageFileInfo
info
;
if
(
!
storage
.
GetInfo
(
relative_uri
.
c_str
(),
true
,
info
,
IgnoreError
()))
try
{
if
(
!
storage
.
GetInfo
(
relative_uri
.
c_str
(),
true
,
info
,
IgnoreError
()))
return
false
;
}
catch
(
const
std
::
runtime_error
&
)
{
return
false
;
return
false
;
}
if
(
!
info
.
IsRegular
())
if
(
!
info
.
IsRegular
())
return
false
;
return
false
;
...
...
src/db/update/UpdateIO.cxx
View file @
100308db
...
@@ -28,34 +28,47 @@
...
@@ -28,34 +28,47 @@
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include <stdexcept>
#include <errno.h>
#include <errno.h>
bool
bool
GetInfo
(
Storage
&
storage
,
const
char
*
uri_utf8
,
StorageFileInfo
&
info
)
GetInfo
(
Storage
&
storage
,
const
char
*
uri_utf8
,
StorageFileInfo
&
info
)
{
try
{
Error
error
;
Error
error
;
bool
success
=
storage
.
GetInfo
(
uri_utf8
,
true
,
info
,
error
);
bool
success
=
storage
.
GetInfo
(
uri_utf8
,
true
,
info
,
error
);
if
(
!
success
)
if
(
!
success
)
LogError
(
error
);
LogError
(
error
);
return
success
;
return
success
;
}
catch
(
const
std
::
runtime_error
&
e
)
{
LogError
(
e
);
return
false
;
}
}
bool
bool
GetInfo
(
StorageDirectoryReader
&
reader
,
StorageFileInfo
&
info
)
GetInfo
(
StorageDirectoryReader
&
reader
,
StorageFileInfo
&
info
)
{
try
{
Error
error
;
Error
error
;
bool
success
=
reader
.
GetInfo
(
true
,
info
,
error
);
bool
success
=
reader
.
GetInfo
(
true
,
info
,
error
);
if
(
!
success
)
if
(
!
success
)
LogError
(
error
);
LogError
(
error
);
return
success
;
return
success
;
}
catch
(
const
std
::
runtime_error
&
e
)
{
LogError
(
e
);
return
false
;
}
}
bool
bool
DirectoryExists
(
Storage
&
storage
,
const
Directory
&
directory
)
DirectoryExists
(
Storage
&
storage
,
const
Directory
&
directory
)
{
{
StorageFileInfo
info
;
StorageFileInfo
info
;
if
(
!
storage
.
GetInfo
(
directory
.
GetPath
(),
true
,
info
,
IgnoreError
()))
try
{
if
(
!
storage
.
GetInfo
(
directory
.
GetPath
(),
true
,
info
,
IgnoreError
()))
return
false
;
}
catch
(
const
std
::
runtime_error
&
)
{
return
false
;
return
false
;
}
return
directory
.
device
==
DEVICE_INARCHIVE
||
return
directory
.
device
==
DEVICE_INARCHIVE
||
directory
.
device
==
DEVICE_CONTAINER
directory
.
device
==
DEVICE_CONTAINER
...
@@ -75,11 +88,13 @@ GetDirectoryChildInfo(Storage &storage, const Directory &directory,
...
@@ -75,11 +88,13 @@ GetDirectoryChildInfo(Storage &storage, const Directory &directory,
bool
bool
directory_child_is_regular
(
Storage
&
storage
,
const
Directory
&
directory
,
directory_child_is_regular
(
Storage
&
storage
,
const
Directory
&
directory
,
const
char
*
name_utf8
)
const
char
*
name_utf8
)
{
try
{
StorageFileInfo
info
;
StorageFileInfo
info
;
return
GetDirectoryChildInfo
(
storage
,
directory
,
name_utf8
,
info
,
return
GetDirectoryChildInfo
(
storage
,
directory
,
name_utf8
,
info
,
IgnoreError
())
&&
IgnoreError
())
&&
info
.
IsRegular
();
info
.
IsRegular
();
}
catch
(
const
std
::
runtime_error
&
)
{
return
false
;
}
}
bool
bool
...
...
src/db/update/Walk.cxx
View file @
100308db
...
@@ -42,11 +42,13 @@
...
@@ -42,11 +42,13 @@
#include "util/Error.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include <stdexcept>
#include <memory>
#include <assert.h>
#include <assert.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
#include <errno.h>
#include <errno.h>
#include <memory>
UpdateWalk
::
UpdateWalk
(
EventLoop
&
_loop
,
DatabaseListener
&
_listener
,
UpdateWalk
::
UpdateWalk
(
EventLoop
&
_loop
,
DatabaseListener
&
_listener
,
Storage
&
_storage
)
Storage
&
_storage
)
...
@@ -333,10 +335,17 @@ UpdateWalk::UpdateDirectory(Directory &directory,
...
@@ -333,10 +335,17 @@ UpdateWalk::UpdateDirectory(Directory &directory,
directory_set_stat
(
directory
,
info
);
directory_set_stat
(
directory
,
info
);
Error
error
;
std
::
unique_ptr
<
StorageDirectoryReader
>
reader
;
const
std
::
unique_ptr
<
StorageDirectoryReader
>
reader
(
storage
.
OpenDirectory
(
directory
.
GetPath
(),
error
));
if
(
reader
.
get
()
==
nullptr
)
{
try
{
LogError
(
error
);
Error
error
;
reader
.
reset
(
storage
.
OpenDirectory
(
directory
.
GetPath
(),
error
));
if
(
!
reader
)
{
LogError
(
error
);
return
false
;
}
}
catch
(
const
std
::
runtime_error
&
e
)
{
LogError
(
e
);
return
false
;
return
false
;
}
}
...
...
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