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
5d01afe3
Commit
5d01afe3
authored
Nov 16, 2015
by
JessonChan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
isOk to check whether the file is latest
parent
d963bb79
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
staticfile.go
staticfile.go
+11
-6
No files found.
staticfile.go
View file @
5d01afe3
...
...
@@ -100,15 +100,13 @@ var (
func
openFile
(
filePath
string
,
fi
os
.
FileInfo
,
acceptEncoding
string
)
(
bool
,
string
,
*
serveContentHolder
,
error
)
{
mapKey
:=
acceptEncoding
+
":"
+
filePath
mapFile
,
ok
:=
staticFileMap
[
mapKey
]
if
ok
{
if
mapFile
.
modTime
==
fi
.
ModTime
()
&&
mapFile
.
size
==
fi
.
Size
()
{
return
mapFile
.
encoding
!=
""
,
mapFile
.
encoding
,
mapFile
,
nil
}
mapFile
,
_
:=
staticFileMap
[
mapKey
]
if
isOk
(
mapFile
,
fi
)
{
return
mapFile
.
encoding
!=
""
,
mapFile
.
encoding
,
mapFile
,
nil
}
mapLock
.
Lock
()
defer
mapLock
.
Unlock
()
if
mapFile
,
ok
=
staticFileMap
[
mapKey
];
!
ok
{
if
mapFile
,
_
=
staticFileMap
[
mapKey
];
!
isOk
(
mapFile
,
fi
)
{
file
,
err
:=
os
.
Open
(
filePath
)
if
err
!=
nil
{
return
false
,
""
,
nil
,
err
...
...
@@ -126,6 +124,13 @@ func openFile(filePath string, fi os.FileInfo, acceptEncoding string) (bool, str
return
mapFile
.
encoding
!=
""
,
mapFile
.
encoding
,
mapFile
,
nil
}
func
isOk
(
s
*
serveContentHolder
,
fi
os
.
FileInfo
)
bool
{
if
s
==
nil
{
return
false
}
return
s
.
modTime
==
fi
.
ModTime
()
&&
s
.
size
==
fi
.
Size
()
}
// isStaticCompress detect static files
func
isStaticCompress
(
filePath
string
)
bool
{
...
...
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