mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-08-30 17:13:08 +08:00
Merge pull request #9568 from wanyaoqi/automated-cherry-pick-of-#9498-upstream-release-3.5
Automated cherry pick of #9498: server migrate misc fix
This commit is contained in:
@@ -209,7 +209,8 @@ func (self *SGuestdisk) GetJsonDescAtHost(host *SHost) jsonutils.JSONObject {
|
||||
localpath := disk.GetPathAtHost(host)
|
||||
if len(localpath) == 0 {
|
||||
desc.Add(jsonutils.JSONTrue, "migrating")
|
||||
disk.SetStatus(nil, api.DISK_START_MIGRATE, "migration")
|
||||
// not used yet
|
||||
// disk.SetStatus(nil, api.DISK_START_MIGRATE, "migration")
|
||||
} else {
|
||||
desc.Add(jsonutils.NewString(localpath), "path")
|
||||
}
|
||||
|
||||
@@ -235,8 +235,25 @@ func (r *SRemoteFile) downloadInternal(getData bool, preChksum string) bool {
|
||||
defer zlibRC.Close()
|
||||
reader = zlibRC
|
||||
}
|
||||
|
||||
var finishChan = make(chan struct{})
|
||||
go func() {
|
||||
defer recover()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(10 * time.Second):
|
||||
info, err := fi.Stat()
|
||||
if err != nil {
|
||||
log.Errorf("failed stat file %s", r.tmpPath)
|
||||
return
|
||||
}
|
||||
log.Infof("written file %s size %dM", r.tmpPath, info.Size()/1024/1024)
|
||||
case <-finishChan:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
_, err = io.Copy(fi, reader)
|
||||
close(finishChan)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user