Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
68b0bd98
Commit
68b0bd98
authored
Nov 06, 2018
by
Viktor Vassilyev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(Template): error handling when reading files
parent
34477984
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
fs.go
fs.go
+7
-0
template.go
template.go
+7
-0
No files found.
fs.go
View file @
68b0bd98
...
...
@@ -40,6 +40,13 @@ func walk(fs http.FileSystem, path string, info os.FileInfo, walkFn filepath.Wal
dir
,
err
:=
fs
.
Open
(
path
)
defer
dir
.
Close
()
if
err
==
nil
{
err1
:=
walkFn
(
path
,
info
,
err
)
if
err1
!=
nil
{
return
err1
}
return
err
}
dirs
,
err
:=
dir
.
Readdir
(
-
1
)
err1
:=
walkFn
(
path
,
info
,
err
)
// If err != nil, walk can't walk into this directory.
...
...
template.go
View file @
68b0bd98
...
...
@@ -327,6 +327,10 @@ func _getTemplate(t0 *template.Template, root string, fs http.FileSystem, subMod
}
data
,
err
=
ioutil
.
ReadAll
(
f
)
f
.
Close
()
if
err
!=
nil
{
logs
.
Trace
(
"template parse file err:"
,
err
)
continue
}
reg
:=
regexp
.
MustCompile
(
BConfig
.
WebConfig
.
TemplateLeft
+
"[ ]*define[ ]+
\"
([^
\"
]+)
\"
"
)
allSub
:=
reg
.
FindAllStringSubmatch
(
string
(
data
),
-
1
)
for
_
,
sub
:=
range
allSub
{
...
...
@@ -337,6 +341,9 @@ func _getTemplate(t0 *template.Template, root string, fs http.FileSystem, subMod
logs
.
Trace
(
"template parse file err:"
,
err
)
}
else
if
len
(
subMods1
)
>
0
{
t
,
err
=
_getTemplate
(
t
,
root
,
fs
,
subMods1
,
others
...
)
if
err
!=
nil
{
logs
.
Trace
(
"template parse file err:"
,
err
)
}
}
break
}
...
...
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