mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-01 01:36:11 +08:00
fix(glance): re-convert as long as subformat is not active
之前的写法会导致saving或者save_fail状态的subformat,不会再次 转换。而且镜像是否需要转换,由ImageCheckTask决定了,ImageConvertTask 只需要注意不重新转换active的subformat就好了,save失败的subformat 也应该设置状态为save_fail。
This commit is contained in:
@@ -118,13 +118,19 @@ func (self *SImageSubformat) DoConvert(image *SImage) error {
|
||||
}
|
||||
|
||||
func (self *SImageSubformat) Save(image *SImage) error {
|
||||
var err error
|
||||
defer func() {
|
||||
if err != nil {
|
||||
db.Update(self, func() error {
|
||||
self.Status = api.IMAGE_STATUS_SAVE_FAIL
|
||||
return nil
|
||||
})
|
||||
}
|
||||
}()
|
||||
if self.Status == api.IMAGE_STATUS_ACTIVE {
|
||||
return nil
|
||||
}
|
||||
if self.Status != api.IMAGE_STATUS_QUEUED {
|
||||
return nil // httperrors.NewInvalidStatusError("cannot save in status %s", self.Status)
|
||||
}
|
||||
_, err := db.Update(self, func() error {
|
||||
_, err = db.Update(self, func() error {
|
||||
self.Status = api.IMAGE_STATUS_SAVING
|
||||
return nil
|
||||
})
|
||||
@@ -166,9 +172,9 @@ func (self *SImageSubformat) SaveTorrent() error {
|
||||
if self.TorrentStatus == api.IMAGE_STATUS_ACTIVE {
|
||||
return nil
|
||||
}
|
||||
if self.TorrentStatus != api.IMAGE_STATUS_QUEUED {
|
||||
return nil // httperrors.NewInvalidStatusError("cannot save torrent in status %s", self.Status)
|
||||
}
|
||||
// if self.TorrentStatus != api.IMAGE_STATUS_QUEUED {
|
||||
// return nil // httperrors.NewInvalidStatusError("cannot save torrent in status %s", self.Status)
|
||||
// }
|
||||
imgPath := self.GetLocalLocation()
|
||||
torrentPath := filepath.Join(options.Options.TorrentStoreDir, fmt.Sprintf("%s.torrent", filepath.Base(imgPath)))
|
||||
_, err := db.Update(self, func() error {
|
||||
|
||||
Reference in New Issue
Block a user