Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
0a0c38fb
提交
0a0c38fb
authored
10月 20, 2014
作者:
Henry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
using @jbenet's industrial lipstick to clean this up
上级
0115d1e0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
77 行增加
和
33 行删除
+77
-33
ipfs.go
cmd/ipfs/ipfs.go
+2
-33
updates.go
updates/updates.go
+75
-0
没有找到文件。
cmd/ipfs/ipfs.go
浏览文件 @
0a0c38fb
...
...
@@ -5,10 +5,8 @@ import (
"fmt"
"os"
"runtime/pprof"
"time"
flag
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
check
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/inconshreveable/go-update/check"
commander
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
...
...
@@ -128,37 +126,8 @@ func localNode(confdir string, online bool) (*core.IpfsNode, error) {
return
nil
,
err
}
if
cfg
.
Version
.
ShouldCheckForUpdate
()
{
log
.
Info
(
"checking for update"
)
u
,
err
:=
updates
.
CheckForUpdate
()
if
err
!=
nil
{
if
err
!=
check
.
NoUpdateAvailable
{
if
cfg
.
Version
.
Check
==
config
.
CheckError
{
log
.
Error
(
"Error while checking for update: %v
\n
"
,
err
)
return
nil
,
err
}
// when "warn" version.check mode we just show a warning message
log
.
Warning
(
err
.
Error
())
}
else
{
// err == check.NoUpdateAvailable
log
.
Notice
(
"No update available, checked on %s"
,
time
.
Now
())
config
.
RecordUpdateCheck
(
cfg
,
filename
)
}
}
else
{
// update avail
if
cfg
.
Version
.
AutoUpdate
!=
config
.
UpdateNever
{
if
updates
.
ShouldAutoUpdate
(
cfg
.
Version
.
AutoUpdate
,
u
.
Version
)
{
log
.
Notice
(
"Applying update %s"
,
u
.
Version
)
if
err
=
updates
.
Apply
(
u
);
err
!=
nil
{
log
.
Error
(
err
.
Error
())
return
nil
,
err
}
// BUG(cryptix): no good way to restart yet. - tracking https://github.com/inconshreveable/go-update/issues/5
fmt
.
Println
(
"update %v applied. please restart."
,
u
.
Version
)
os
.
Exit
(
0
)
}
}
}
if
err
:=
updates
.
CliCheckForUpdates
(
cfg
,
filename
);
err
!=
nil
{
return
nil
,
err
}
return
core
.
NewIpfsNode
(
cfg
,
online
)
...
...
updates/updates.go
浏览文件 @
0a0c38fb
...
...
@@ -3,6 +3,7 @@ package updates
import
(
"fmt"
"os"
"time"
"github.com/jbenet/go-ipfs/config"
u
"github.com/jbenet/go-ipfs/util"
...
...
@@ -122,3 +123,77 @@ func ShouldAutoUpdate(setting config.AutoUpdateSetting, newVer string) bool {
return
false
}
func
CliCheckForUpdates
(
cfg
*
config
.
Config
,
confFile
string
)
error
{
// if config says not to, don't check for updates
if
!
cfg
.
Version
.
ShouldCheckForUpdate
()
{
log
.
Info
(
"update checking disabled."
)
return
nil
}
log
.
Info
(
"checking for update"
)
u
,
err
:=
CheckForUpdate
()
// if there is no update available, record it, and exit.
if
err
==
check
.
NoUpdateAvailable
{
log
.
Notice
(
"No update available, checked on %s"
,
time
.
Now
())
config
.
RecordUpdateCheck
(
cfg
,
confFile
)
// only record if we checked successfully.
return
nil
}
// if another, unexpected error occurred, note it.
if
err
!=
nil
{
if
cfg
.
Version
.
Check
==
config
.
CheckError
{
log
.
Error
(
"Error while checking for update: %v
\n
"
,
err
)
return
nil
}
// when "warn" version.check mode we just show a warning message
log
.
Warning
(
err
.
Error
())
return
nil
}
// there is an update available
// if we autoupdate
if
cfg
.
Version
.
AutoUpdate
!=
config
.
UpdateNever
{
// and we should auto update
if
ShouldAutoUpdate
(
cfg
.
Version
.
AutoUpdate
,
u
.
Version
)
{
log
.
Notice
(
"Applying update %s"
,
u
.
Version
)
if
err
=
Apply
(
u
);
err
!=
nil
{
log
.
Error
(
err
.
Error
())
return
nil
}
// BUG(cryptix): no good way to restart yet. - tracking https://github.com/inconshreveable/go-update/issues/5
fmt
.
Println
(
"update %v applied. please restart."
,
u
.
Version
)
os
.
Exit
(
0
)
}
}
// autoupdate did not exit, so regular notices.
switch
cfg
.
Version
.
Check
{
case
config
.
CheckError
:
return
fmt
.
Errorf
(
errShouldUpdate
,
Version
,
u
.
Version
)
case
config
.
CheckWarn
:
// print the warning
fmt
.
Printf
(
"New version available: %s"
,
u
.
Version
)
default
:
// ignore
}
return
nil
}
var
errShouldUpdate
=
`
Your go-ipfs version is: %s
There is a new version available: %s
Since this is alpha software, it is strongly recommended you update.
To update, run:
ipfs update apply
To disable this notice, run:
ipfs config Version.Check warn
`
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论