Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
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
guxukai
baas-ide
Commits
abeccd51
Commit
abeccd51
authored
Jan 19, 2017
by
Alex Beregszaszi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include comprehensive error handling in files API (always return true/false)
parent
60fc07ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
files.js
src/app/files.js
+22
-7
No files found.
src/app/files.js
View file @
abeccd51
...
@@ -10,7 +10,7 @@ function Files (storage) {
...
@@ -10,7 +10,7 @@ function Files (storage) {
this
.
exists
=
function
(
path
)
{
this
.
exists
=
function
(
path
)
{
// NOTE: ignore the config file
// NOTE: ignore the config file
if
(
path
===
'.browser-solidity.json'
)
{
if
(
path
===
'.browser-solidity.json'
)
{
return
return
false
}
}
if
(
this
.
isReadOnly
(
path
))
{
if
(
this
.
isReadOnly
(
path
))
{
...
@@ -23,7 +23,7 @@ function Files (storage) {
...
@@ -23,7 +23,7 @@ function Files (storage) {
this
.
get
=
function
(
path
)
{
this
.
get
=
function
(
path
)
{
// NOTE: ignore the config file
// NOTE: ignore the config file
if
(
path
===
'.browser-solidity.json'
)
{
if
(
path
===
'.browser-solidity.json'
)
{
return
return
null
}
}
if
(
this
.
isReadOnly
(
path
))
{
if
(
this
.
isReadOnly
(
path
))
{
...
@@ -36,25 +36,33 @@ function Files (storage) {
...
@@ -36,25 +36,33 @@ function Files (storage) {
this
.
set
=
function
(
path
,
content
)
{
this
.
set
=
function
(
path
,
content
)
{
// NOTE: ignore the config file
// NOTE: ignore the config file
if
(
path
===
'.browser-solidity.json'
)
{
if
(
path
===
'.browser-solidity.json'
)
{
return
return
false
}
}
if
(
!
this
.
isReadOnly
(
path
))
{
if
(
!
this
.
isReadOnly
(
path
))
{
var
exists
=
storage
.
exists
(
path
)
var
exists
=
storage
.
exists
(
path
)
storage
.
set
(
path
,
content
)
if
(
!
storage
.
set
(
path
,
content
))
{
return
false
}
if
(
!
exists
)
{
if
(
!
exists
)
{
event
.
trigger
(
'fileAdded'
,
[
path
])
event
.
trigger
(
'fileAdded'
,
[
path
])
}
else
{
}
else
{
event
.
trigger
(
'fileChanged'
,
[
path
])
event
.
trigger
(
'fileChanged'
,
[
path
])
}
}
return
true
}
}
return
false
}
}
this
.
addReadOnly
=
function
(
path
,
content
)
{
this
.
addReadOnly
=
function
(
path
,
content
)
{
if
(
!
storage
.
exists
(
path
))
{
if
(
!
storage
.
exists
(
path
))
{
readonly
[
path
]
=
content
readonly
[
path
]
=
content
event
.
trigger
(
'fileAdded'
,
[
path
])
event
.
trigger
(
'fileAdded'
,
[
path
])
return
true
}
}
return
false
}
}
this
.
isReadOnly
=
function
(
path
)
{
this
.
isReadOnly
=
function
(
path
)
{
...
@@ -63,22 +71,29 @@ function Files (storage) {
...
@@ -63,22 +71,29 @@ function Files (storage) {
this
.
remove
=
function
(
path
)
{
this
.
remove
=
function
(
path
)
{
if
(
!
this
.
exists
(
path
))
{
if
(
!
this
.
exists
(
path
))
{
return
return
false
}
}
if
(
this
.
isReadOnly
(
path
))
{
if
(
this
.
isReadOnly
(
path
))
{
readonly
[
path
]
=
undefined
readonly
[
path
]
=
undefined
}
else
{
}
else
{
storage
.
remove
(
path
)
if
(
!
storage
.
remove
(
path
))
{
return
false
}
}
}
event
.
trigger
(
'fileRemoved'
,
[
path
])
event
.
trigger
(
'fileRemoved'
,
[
path
])
return
true
}
}
this
.
rename
=
function
(
oldPath
,
newPath
)
{
this
.
rename
=
function
(
oldPath
,
newPath
)
{
if
(
!
this
.
isReadOnly
(
oldPath
)
&&
storage
.
exists
(
oldPath
))
{
if
(
!
this
.
isReadOnly
(
oldPath
)
&&
storage
.
exists
(
oldPath
))
{
storage
.
rename
(
oldPath
,
newPath
)
if
(
!
storage
.
rename
(
oldPath
,
newPath
))
{
return
false
}
event
.
trigger
(
'fileRenamed'
,
[
oldPath
,
newPath
])
event
.
trigger
(
'fileRenamed'
,
[
oldPath
,
newPath
])
return
true
}
}
return
false
}
}
this
.
list
=
function
()
{
this
.
list
=
function
()
{
...
...
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