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
Hide 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
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Net
;
using
System.Net
;
...
@@ -43,10 +42,10 @@ namespace Breeze.Wallet.Controllers
...
@@ -43,10 +42,10 @@ namespace Breeze.Wallet.Controllers
try
try
{
{
// get the
folder path
// get the
wallet folder
string
folderPath
=
string
.
IsNullOrEmpty
(
request
.
FolderPath
)
?
this
.
GetDefaultFolderPath
()
:
request
.
FolderPath
;
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
);
return
this
.
Json
(
mnemonic
);
}
}
catch
(
NotSupportedException
e
)
catch
(
NotSupportedException
e
)
...
@@ -74,10 +73,10 @@ namespace Breeze.Wallet.Controllers
...
@@ -74,10 +73,10 @@ namespace Breeze.Wallet.Controllers
try
try
{
{
// get the
folder path
// get the
wallet folder
string
folderPath
=
string
.
IsNullOrEmpty
(
request
.
FolderPath
)
?
this
.
GetDefaultFolderPath
()
:
request
.
FolderPath
;
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
);
return
this
.
Json
(
wallet
);
}
}
...
@@ -114,12 +113,11 @@ namespace Breeze.Wallet.Controllers
...
@@ -114,12 +113,11 @@ namespace Breeze.Wallet.Controllers
try
try
{
{
// get the
folder path
// get the
wallet folder
string
folderPath
=
string
.
IsNullOrEmpty
(
request
.
FolderPath
)
?
this
.
GetDefaultFolderPath
()
:
request
.
FolderPath
;
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
);
return
this
.
Json
(
wallet
);
}
}
catch
(
FileNotFoundException
e
)
catch
(
FileNotFoundException
e
)
{
{
...
@@ -287,12 +285,12 @@ namespace Breeze.Wallet.Controllers
...
@@ -287,12 +285,12 @@ namespace Breeze.Wallet.Controllers
{
{
try
try
{
{
var
defaultWalletsPath
=
this
.
GetDefaultFolderPath
();
DirectoryInfo
walletsFolder
=
GetWalletFolder
();
WalletFileModel
model
=
new
WalletFileModel
WalletFileModel
model
=
new
WalletFileModel
{
{
WalletsPath
=
defaultWalletsPath
,
WalletsPath
=
walletsFolder
.
FullName
,
WalletsFiles
=
Directory
.
EnumerateFiles
(
defaultWalletsPath
,
"*.json"
,
SearchOption
.
TopDirectoryOnly
).
Select
(
p
=>
Path
.
GetFileName
(
p
))
WalletsFiles
=
Directory
.
EnumerateFiles
(
walletsFolder
.
FullName
,
"*.json"
,
SearchOption
.
TopDirectoryOnly
).
Select
(
p
=>
Path
.
GetFileName
(
p
))
};
};
return
this
.
Json
(
model
);
return
this
.
Json
(
model
);
...
@@ -304,11 +302,25 @@ namespace Breeze.Wallet.Controllers
...
@@ -304,11 +302,25 @@ namespace Breeze.Wallet.Controllers
}
}
/// <summary>
/// <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>
/// </summary>
/// <returns>The folder path for Windows, Linux or OSX systems.</returns>
/// <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
))
if
(
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Windows
))
{
{
return
$@"
{
Environment
.
GetEnvironmentVariable
(
"AppData"
)}
\Breeze"
;
return
$@"
{
Environment
.
GetEnvironmentVariable
(
"AppData"
)}
\Breeze"
;
...
...
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