Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Juicedata
JuiceFS
提交
c94df2b1
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,发现更多精彩内容 >>
提交
c94df2b1
编写于
12月 20, 2020
作者:
D
Davies Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update progress for deleted or failed objects
上级
75276885
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
20 deletion
+26
-20
sync/sync.go
sync/sync.go
+26
-20
未找到文件。
sync/sync.go
浏览文件 @
c94df2b1
...
...
@@ -32,7 +32,7 @@ const (
var
(
found
int64
missing
int64
todo
int64
copied
int64
copiedBytes
int64
failed
int64
...
...
@@ -372,7 +372,14 @@ func worker(todo chan *object.Object, src, dst object.ObjectStorage, config *con
}
}
func
producer
(
todo
chan
*
object
.
Object
,
src
,
dst
object
.
ObjectStorage
,
config
*
config
.
Config
)
{
func
deleteFromDst
(
tasks
chan
*
object
.
Object
,
dstobj
*
object
.
Object
)
{
dstobj
.
Size
=
markDelete
tasks
<-
dstobj
atomic
.
AddInt64
(
&
found
,
1
)
atomic
.
AddInt64
(
&
todo
,
1
)
}
func
producer
(
tasks
chan
*
object
.
Object
,
src
,
dst
object
.
ObjectStorage
,
config
*
config
.
Config
)
{
start
,
end
:=
config
.
Start
,
config
.
End
logger
.
Infof
(
"Syncing from %s to %s"
,
src
,
dst
)
if
start
!=
""
{
...
...
@@ -419,8 +426,7 @@ OUT:
// ignore
logger
.
Debug
(
"Ignore deleting dst directory "
,
dstobj
.
Key
)
}
else
{
dstobj
.
Size
=
markDelete
todo
<-
dstobj
deleteFromDst
(
tasks
,
dstobj
)
}
}
dstobj
,
ok
=
<-
dstkeys
...
...
@@ -437,17 +443,19 @@ OUT:
if
!
hasMore
||
obj
.
Key
<
dstobj
.
Key
||
obj
.
Key
==
dstobj
.
Key
&&
(
config
.
ForceUpdate
||
obj
.
Size
!=
dstobj
.
Size
||
config
.
Update
&&
obj
.
Mtime
.
Unix
()
>
dstobj
.
Mtime
.
Unix
())
{
t
odo
<-
obj
atomic
.
AddInt64
(
&
missing
,
1
)
t
asks
<-
obj
atomic
.
AddInt64
(
&
todo
,
1
)
}
else
if
config
.
DeleteSrc
&&
dstobj
!=
nil
&&
obj
.
Key
==
dstobj
.
Key
&&
obj
.
Size
==
dstobj
.
Size
{
obj
.
Size
=
markDelete
todo
<-
obj
tasks
<-
obj
atomic
.
AddInt64
(
&
todo
,
1
)
}
else
if
config
.
Perms
{
f1
:=
(
*
object
.
File
)(
unsafe
.
Pointer
(
obj
))
f2
:=
(
*
object
.
File
)(
unsafe
.
Pointer
(
dstobj
))
if
f2
.
Mode
!=
f1
.
Mode
||
f2
.
Owner
!=
f1
.
Owner
||
f2
.
Group
!=
f1
.
Group
{
obj
.
Size
=
markCopyPerms
todo
<-
obj
tasks
<-
obj
atomic
.
AddInt64
(
&
todo
,
1
)
}
}
if
dstobj
!=
nil
&&
dstobj
.
Key
==
obj
.
Key
{
...
...
@@ -456,31 +464,29 @@ OUT:
}
if
config
.
DeleteDst
&&
hasMore
{
if
dstobj
!=
nil
{
dstobj
.
Size
=
markDelete
todo
<-
dstobj
deleteFromDst
(
tasks
,
dstobj
)
}
for
obj
:=
range
dstkeys
{
if
obj
!=
nil
{
obj
.
Size
=
markDelete
todo
<-
obj
deleteFromDst
(
tasks
,
obj
)
}
}
}
close
(
t
odo
)
close
(
t
asks
)
}
func
showProgress
()
{
var
last
Copied
,
lastBytes
[]
int64
var
last
Done
,
lastBytes
[]
int64
var
lastTime
[]
time
.
Time
for
{
if
found
==
0
{
time
.
Sleep
(
time
.
Millisecond
*
10
)
continue
}
same
:=
atomic
.
LoadInt64
(
&
found
)
-
atomic
.
LoadInt64
(
&
missing
)
same
:=
atomic
.
LoadInt64
(
&
found
)
-
atomic
.
LoadInt64
(
&
todo
)
var
width
int64
=
45
a
:=
width
*
same
/
found
b
:=
width
*
copied
/
found
b
:=
width
*
(
copied
+
deleted
+
failed
)
/
found
var
bar
[
80
]
byte
var
i
int64
for
i
=
0
;
i
<
width
;
i
++
{
...
...
@@ -493,20 +499,20 @@ func showProgress() {
}
}
now
:=
time
.
Now
()
last
Copied
=
append
(
lastCopied
,
copi
ed
)
last
Done
=
append
(
lastDone
,
copied
+
deleted
+
fail
ed
)
lastBytes
=
append
(
lastBytes
,
copiedBytes
)
lastTime
=
append
(
lastTime
,
now
)
for
len
(
lastTime
)
>
18
{
// 5 seconds
last
Copied
=
lastCopied
[
1
:
]
last
Done
=
lastDone
[
1
:
]
lastBytes
=
lastBytes
[
1
:
]
lastTime
=
lastTime
[
1
:
]
}
if
len
(
lastTime
)
>
1
{
n
:=
len
(
lastTime
)
-
1
d
:=
lastTime
[
n
]
.
Sub
(
lastTime
[
0
])
.
Seconds
()
fps
:=
float64
(
last
Copied
[
n
]
-
lastCopied
[
0
])
/
d
fps
:=
float64
(
last
Done
[
n
]
-
lastDone
[
0
])
/
d
bw
:=
float64
(
lastBytes
[
n
]
-
lastBytes
[
0
])
/
d
/
1024
/
1024
fmt
.
Printf
(
"[%s] % 8d % 2d%% % 4.1f/s % 4.1f MB/s
\r
"
,
string
(
bar
[
:
]),
found
,
(
found
-
missing
+
copi
ed
)
*
100
/
found
,
fps
,
bw
)
fmt
.
Printf
(
"[%s] % 8d % 2d%% % 4.1f/s % 4.1f MB/s
\r
"
,
string
(
bar
[
:
]),
found
,
(
found
-
todo
+
copied
+
deleted
+
fail
ed
)
*
100
/
found
,
fps
,
bw
)
}
time
.
Sleep
(
time
.
Millisecond
*
300
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录