Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Juicedata
JuiceFS
提交
2fe9c7a1
JuiceFS
项目概览
Juicedata
/
JuiceFS
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
JuiceFS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2fe9c7a1
编写于
1月 29, 2021
作者:
D
Davies Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
verify volume name
上级
da163c17
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
9 deletion
+10
-9
cmd/format.go
cmd/format.go
+8
-2
pkg/meta/redis.go
pkg/meta/redis.go
+2
-7
未找到文件。
cmd/format.go
浏览文件 @
2fe9c7a1
...
...
@@ -23,6 +23,7 @@ import (
_
"net/http/pprof"
"os"
"path"
"regexp"
"runtime"
"strings"
"time"
...
...
@@ -130,7 +131,7 @@ func format(c *cli.Context) error {
addr
=
"redis://"
+
addr
}
logger
.
Infof
(
"Meta address: %s"
,
addr
)
var
rc
=
meta
.
RedisConfig
{
Retries
:
10
}
var
rc
=
meta
.
RedisConfig
{
Retries
:
2
}
m
,
err
:=
meta
.
NewRedisMeta
(
addr
,
&
rc
)
if
err
!=
nil
{
logger
.
Fatalf
(
"Meta is not available: %s"
,
err
)
...
...
@@ -139,13 +140,18 @@ func format(c *cli.Context) error {
if
c
.
Args
()
.
Len
()
<
2
{
logger
.
Fatalf
(
"Please give it a name"
)
}
name
:=
c
.
Args
()
.
Get
(
1
)
validName
:=
regexp
.
MustCompile
(
`^[a-z0-9][a-z0-9\-]{1,61}[a-z0-9]$`
)
if
!
validName
.
MatchString
(
name
)
{
logger
.
Fatalf
(
"invalid name: %s, only alphabet, number and - are allowed."
,
name
)
}
compressor
:=
compress
.
NewCompressor
(
c
.
String
(
"compress"
))
if
compressor
==
nil
{
logger
.
Fatalf
(
"Unsupported compress algorithm: %s"
,
c
.
String
(
"compress"
))
}
format
:=
meta
.
Format
{
Name
:
c
.
Args
()
.
Get
(
1
)
,
Name
:
name
,
UUID
:
uuid
.
New
()
.
String
(),
Storage
:
c
.
String
(
"storage"
),
Bucket
:
c
.
String
(
"bucket"
),
...
...
pkg/meta/redis.go
浏览文件 @
2fe9c7a1
...
...
@@ -134,7 +134,7 @@ func NewRedisMeta(url string, conf *RedisConfig) (Meta, error) {
m
.
shaLookup
,
err
=
m
.
rdb
.
ScriptLoad
(
Background
,
scriptLookup
)
.
Result
()
if
err
!=
nil
{
logger
.
Infof
(
"Failed to
load scriptLookup: %v"
,
err
)
logger
.
Warnf
(
"
load scriptLookup: %v"
,
err
)
m
.
shaLookup
=
""
}
...
...
@@ -188,21 +188,16 @@ func (r *redisMeta) Init(format Format, force bool) error {
// root inode
var
attr
Attr
attr
.
Flags
=
0
attr
.
Typ
=
TypeDirectory
attr
.
Mode
=
0777
attr
.
Uid
=
0
attr
.
Uid
=
0
ts
:=
time
.
Now
()
.
Unix
()
attr
.
Atime
=
ts
attr
.
Mtime
=
ts
attr
.
Ctime
=
ts
attr
.
Nlink
=
2
attr
.
Length
=
4
<<
10
attr
.
Rdev
=
0
attr
.
Parent
=
1
r
.
rdb
.
Set
(
Background
,
r
.
inodeKey
(
1
),
r
.
marshal
(
&
attr
),
0
)
return
nil
return
r
.
rdb
.
Set
(
Background
,
r
.
inodeKey
(
1
),
r
.
marshal
(
&
attr
),
0
)
.
Err
()
}
func
(
r
*
redisMeta
)
Load
()
(
*
Format
,
error
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录