Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hexbee
Cloudreve
提交
fa900b16
C
Cloudreve
项目概览
hexbee
/
Cloudreve
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cloudreve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa900b16
编写于
4月 08, 2020
作者:
H
HFO4
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Feat: check static files version
上级
2e43f8ed
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
1 deletion
+46
-1
assets
assets
+1
-1
bootstrap/static.go
bootstrap/static.go
+42
-0
pkg/conf/version.go
pkg/conf/version.go
+3
-0
未找到文件。
assets
@
43c9ce1d
比较
f544486b
...
43c9ce1d
Subproject commit
f544486b6ae2440df197630601b1827ed6977c0b
Subproject commit
43c9ce1d266050637a247113db54883ce2218291
bootstrap/static.go
浏览文件 @
fa900b16
package
bootstrap
import
(
"encoding/json"
"github.com/HFO4/cloudreve/pkg/conf"
"github.com/HFO4/cloudreve/pkg/util"
_
"github.com/HFO4/cloudreve/statik"
"github.com/gin-contrib/static"
"github.com/rakyll/statik/fs"
"io/ioutil"
"net/http"
)
...
...
@@ -12,6 +15,11 @@ type GinFS struct {
FS
http
.
FileSystem
}
type
staticVersion
struct
{
Name
string
`json:"name"`
Version
string
`json:"version"`
}
// StaticFS 内置静态文件资源
var
StaticFS
static
.
ServeFileSystem
...
...
@@ -45,4 +53,38 @@ func InitStatic() {
}
}
// 检查静态资源的版本
f
,
err
:=
StaticFS
.
Open
(
"version.json"
)
if
err
!=
nil
{
util
.
Log
()
.
Warning
(
"静态资源版本标识文件不存在,请重新构建或删除 statics 目录"
)
return
}
b
,
err
:=
ioutil
.
ReadAll
(
f
)
if
err
!=
nil
{
util
.
Log
()
.
Warning
(
"无法读取静态资源文件版本,请重新构建或删除 statics 目录"
)
return
}
var
v
staticVersion
if
err
:=
json
.
Unmarshal
(
b
,
&
v
);
err
!=
nil
{
util
.
Log
()
.
Warning
(
"无法解析静态资源文件版本, %s"
,
err
)
return
}
staticName
:=
"cloudreve-frontend"
if
conf
.
IsPro
==
"true"
{
staticName
+=
"-pro"
}
if
v
.
Name
!=
staticName
{
util
.
Log
()
.
Warning
(
"静态资源版本不匹配,请重新构建或删除 statics 目录"
)
return
}
if
v
.
Version
!=
conf
.
RequiredStaticVersion
{
util
.
Log
()
.
Warning
(
"静态资源版本不匹配 [当前 %s, 需要: %s],请重新构建或删除 statics 目录"
,
v
.
Version
,
conf
.
RequiredStaticVersion
)
return
}
}
pkg/conf/version.go
浏览文件 @
fa900b16
...
...
@@ -6,6 +6,9 @@ var BackendVersion = "3.0.0-beta1"
// RequiredDBVersion 与当前版本匹配的数据库版本
var
RequiredDBVersion
=
"3.0.0-rc1"
// RequiredStaticVersion 与当前版本匹配的静态资源版本
var
RequiredStaticVersion
=
"3.0.0"
// IsPro 是否为Pro版本
var
IsPro
=
"false"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录