Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
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
DeStream-public
Breeze
Commits
4be0a960
Commit
4be0a960
authored
Apr 14, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made sure the wallet folder exists or creating it if it doesn't
parent
09435caa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
17 deletions
+29
-17
WalletController.cs
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
+29
-17
No files found.
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
View file @
4be0a960
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
...
...
@@ -43,10 +42,10 @@ namespace Breeze.Wallet.Controllers
try
{
// get the
folder path
string
folderPath
=
string
.
IsNullOrEmpty
(
request
.
FolderPath
)
?
this
.
GetDefaultFolderPath
()
:
request
.
FolderPath
;
// get the
wallet folder
DirectoryInfo
walletFolder
=
GetWalletFolder
(
request
.
FolderPath
)
;
var
mnemonic
=
this
.
walletWrapper
.
Create
(
request
.
Password
,
folderPath
,
request
.
Name
,
request
.
Network
);
var
mnemonic
=
this
.
walletWrapper
.
Create
(
request
.
Password
,
walletFolder
.
FullName
,
request
.
Name
,
request
.
Network
);
return
this
.
Json
(
mnemonic
);
}
catch
(
NotSupportedException
e
)
...
...
@@ -74,10 +73,10 @@ namespace Breeze.Wallet.Controllers
try
{
// get the
folder path
string
folderPath
=
string
.
IsNullOrEmpty
(
request
.
FolderPath
)
?
this
.
GetDefaultFolderPath
()
:
request
.
FolderPath
;
// get the
wallet folder
DirectoryInfo
walletFolder
=
GetWalletFolder
(
request
.
FolderPath
)
;
var
wallet
=
this
.
walletWrapper
.
Load
(
request
.
Password
,
folderPath
,
request
.
Name
);
var
wallet
=
this
.
walletWrapper
.
Load
(
request
.
Password
,
walletFolder
.
FullName
,
request
.
Name
);
return
this
.
Json
(
wallet
);
}
...
...
@@ -114,12 +113,11 @@ namespace Breeze.Wallet.Controllers
try
{
// get the
folder path
string
folderPath
=
string
.
IsNullOrEmpty
(
request
.
FolderPath
)
?
this
.
GetDefaultFolderPath
()
:
request
.
FolderPath
;
// get the
wallet folder
DirectoryInfo
walletFolder
=
GetWalletFolder
(
request
.
FolderPath
)
;
var
wallet
=
this
.
walletWrapper
.
Recover
(
request
.
Password
,
folderPath
,
request
.
Name
,
request
.
Network
,
request
.
Mnemonic
);
var
wallet
=
this
.
walletWrapper
.
Recover
(
request
.
Password
,
walletFolder
.
FullName
,
request
.
Name
,
request
.
Network
,
request
.
Mnemonic
);
return
this
.
Json
(
wallet
);
}
catch
(
FileNotFoundException
e
)
{
...
...
@@ -287,12 +285,12 @@ namespace Breeze.Wallet.Controllers
{
try
{
var
defaultWalletsPath
=
this
.
GetDefaultFolderPath
();
DirectoryInfo
walletsFolder
=
GetWalletFolder
();
WalletFileModel
model
=
new
WalletFileModel
{
WalletsPath
=
defaultWalletsPath
,
WalletsFiles
=
Directory
.
EnumerateFiles
(
defaultWalletsPath
,
"*.json"
,
SearchOption
.
TopDirectoryOnly
).
Select
(
p
=>
Path
.
GetFileName
(
p
))
WalletsPath
=
walletsFolder
.
FullName
,
WalletsFiles
=
Directory
.
EnumerateFiles
(
walletsFolder
.
FullName
,
"*.json"
,
SearchOption
.
TopDirectoryOnly
).
Select
(
p
=>
Path
.
GetFileName
(
p
))
};
return
this
.
Json
(
model
);
...
...
@@ -304,10 +302,24 @@ namespace Breeze.Wallet.Controllers
}
/// <summary>
/// Get the default folder in which the wallets will be stored.
/// Gets a folder.
/// </summary>
/// <returns>The path folder of the folder.</returns>
/// <remarks>The folder is created if it doesn't exist.</remarks>
private
static
DirectoryInfo
GetWalletFolder
(
string
folderPath
=
null
)
{
if
(
string
.
IsNullOrEmpty
(
folderPath
))
{
folderPath
=
GetDefaultWalletFolderPath
();
}
return
Directory
.
CreateDirectory
(
folderPath
);
}
/// <summary>
/// Gets the path of the default folder in which the wallets will be stored.
/// </summary>
/// <returns>The folder path for Windows, Linux or OSX systems.</returns>
private
st
ring
GetDefaul
tFolderPath
()
private
st
atic
string
GetDefaultWalle
tFolderPath
()
{
if
(
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Windows
))
{
...
...
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