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
df142d4f
Commit
df142d4f
authored
Oct 29, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple: migrate Mount() from class Error to C++ exceptions
parent
fac8edd4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
16 deletions
+8
-16
StorageCommands.cxx
src/command/StorageCommands.cxx
+1
-6
SimpleDatabasePlugin.cxx
src/db/plugins/simple/SimpleDatabasePlugin.cxx
+3
-8
SimpleDatabasePlugin.hxx
src/db/plugins/simple/SimpleDatabasePlugin.hxx
+4
-2
No files found.
src/command/StorageCommands.cxx
View file @
df142d4f
...
...
@@ -24,7 +24,6 @@
#include "Request.hxx"
#include "CommandError.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/ConstBuffer.hxx"
#include "fs/Traits.hxx"
#include "client/Client.hxx"
...
...
@@ -211,11 +210,7 @@ handle_mount(Client &client, Request args, Response &r)
SimpleDatabase
&
db
=
*
(
SimpleDatabase
*
)
_db
;
try
{
Error
error
;
if
(
!
db
.
Mount
(
local_uri
,
remote_uri
,
error
))
{
composite
.
Unmount
(
local_uri
);
return
print_error
(
r
,
error
);
}
db
.
Mount
(
local_uri
,
remote_uri
);
}
catch
(...)
{
composite
.
Unmount
(
local_uri
);
throw
;
...
...
src/db/plugins/simple/SimpleDatabasePlugin.cxx
View file @
df142d4f
...
...
@@ -395,9 +395,8 @@ IsUnsafeChar(char ch)
return
!
IsSafeChar
(
ch
);
}
bool
SimpleDatabase
::
Mount
(
const
char
*
local_uri
,
const
char
*
storage_uri
,
Error
&
error
)
void
SimpleDatabase
::
Mount
(
const
char
*
local_uri
,
const
char
*
storage_uri
)
{
if
(
cache_path
.
IsNull
())
throw
DatabaseError
(
DatabaseErrorCode
::
NOT_FOUND
,
...
...
@@ -406,9 +405,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri,
std
::
string
name
(
storage_uri
);
std
::
replace_if
(
name
.
begin
(),
name
.
end
(),
IsUnsafeChar
,
'_'
);
const
auto
name_fs
=
AllocatedPath
::
FromUTF8
(
name
.
c_str
(),
error
);
if
(
name_fs
.
IsNull
())
return
false
;
const
auto
name_fs
=
AllocatedPath
::
FromUTF8Throw
(
name
.
c_str
());
#ifndef ENABLE_ZLIB
constexpr
bool
compress
=
false
;
...
...
@@ -432,8 +429,6 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri,
delete
db
;
throw
;
}
return
true
;
}
Database
*
...
...
src/db/plugins/simple/SimpleDatabasePlugin.hxx
View file @
df142d4f
...
...
@@ -98,9 +98,11 @@ public:
gcc_nonnull_all
void
Mount
(
const
char
*
uri
,
Database
*
db
);
/**
* Throws #std::runtime_error on error.
*/
gcc_nonnull_all
bool
Mount
(
const
char
*
local_uri
,
const
char
*
storage_uri
,
Error
&
error
);
void
Mount
(
const
char
*
local_uri
,
const
char
*
storage_uri
);
gcc_nonnull_all
bool
Unmount
(
const
char
*
uri
);
...
...
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