* fix bug

* updata UI

* 0.3.2

### Added

- [Files] Files can now be selected multiple files and downloaded, deleted, moved, etc.
- [Apps] Support to modify the application opening address.([#204](https://github.com/IceWhaleTech/CasaOS/issues/204))

### Changed

- [Apps] Hide the display of non-essential environment variables in the application.
- [System] Network, disk, cpu, memory, etc. information is modified to be pushed via socket.
- [System] Optimize opening speed.([#214](https://github.com/IceWhaleTech/CasaOS/issues/214))
### Fixed

- [System] Fixed the problem that sync data cannot submit the device ID ([#68](https://github.com/IceWhaleTech/CasaOS/issues/68))
- [Files] Fixed the code editor center alignment display problem.([#210](https://github.com/IceWhaleTech/CasaOS/issues/210))
- [Files] Fixed the problem of wrong name when downloading files.([#240](https://github.com/IceWhaleTech/CasaOS/issues/240))
- [System] Fixed the network display as a negative number problem.([#224](https://github.com/IceWhaleTech/CasaOS/issues/224))

* Modify log help class

* Fix some bugs in 0.3.2

* Solve the operation file queue problem

* Exclude web folders

* update UI

* add cancel file operate
This commit is contained in:
link 2022-06-08 19:31:01 +08:00 committed by GitHub
parent d4bed3e5c7
commit eaf2341a2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 120 additions and 9 deletions

View file

@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
## [0.3.2-pre]
## [0.3.2-pre] - 2022-06-08
### Added

View file

@ -152,6 +152,7 @@ func InitRouter() *gin.Engine {
v1FileGroup.DELETE("/delete", v1.DeleteFile)
v1FileGroup.PUT("/update", v1.PutFileContent)
v1FileGroup.GET("/image", v1.GetFileImage)
v1FileGroup.DELETE("/operate/:id", v1.DeleteOperateFileOrDir)
//v1FileGroup.GET("/download", v1.UserFileDownloadCommonService)
}

View file

@ -15,6 +15,7 @@ import (
"path/filepath"
"strconv"
"strings"
"sync"
"github.com/IceWhaleTech/CasaOS/model"
"github.com/IceWhaleTech/CasaOS/pkg/config"
@ -198,6 +199,7 @@ func GetDownloadFile(c *gin.Context) {
defer ar.Close()
commonDir := file.CommonPrefix(filepath.Separator, list...)
currentPath := filepath.Base(commonDir)
name := "_" + currentPath
@ -514,7 +516,9 @@ func PostOperateFileOrDir(c *gin.Context) {
if len(service.OpStrArr) == 1 {
go service.ExecOpFile()
go service.CheckFileStatus()
go service.MyService.Notify().SendFileOperateNotify()
go service.MyService.Notify().SendFileOperateNotify(false)
}
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS)})
@ -623,3 +627,25 @@ func GetFileImage(c *gin.Context) {
}
c.Writer.WriteString(string(data))
}
func DeleteOperateFileOrDir(c *gin.Context) {
id := c.Param("id")
if id == "0" {
service.FileQueue = sync.Map{}
service.OpStrArr = []string{}
} else {
service.FileQueue.Delete(id)
tempList := []string{}
for _, v := range service.OpStrArr {
if v != id {
tempList = append(tempList, v)
}
}
service.OpStrArr = tempList
}
go service.MyService.Notify().SendFileOperateNotify(true)
c.JSON(http.StatusOK, model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS)})
}

View file

@ -35,7 +35,7 @@ type NotifyServer interface {
SendUSBInfoBySocket(list []model2.DriveUSB)
SendDiskInfoBySocket(disk model2.Summary)
SendPersonStatusBySocket(status notify.Person)
SendFileOperateNotify()
SendFileOperateNotify(nowSend bool)
SendInstallAppBySocket(app notify.Application)
}
@ -44,19 +44,34 @@ type notifyServer struct {
}
// Send periodic broadcast messages
func (i *notifyServer) SendFileOperateNotify() {
for {
func (i *notifyServer) SendFileOperateNotify(nowSend bool) {
if nowSend {
len := 0
FileQueue.Range(func(k, v interface{}) bool {
len++
return true
})
model := notify.NotifyModel{}
listMsg := make(map[string]interface{})
if len == 0 {
model.Data = []string{}
listMsg["file_operate"] = model
msg := gosf.Message{}
msg.Success = true
msg.Body = listMsg
msg.Text = "file_operate"
notify := notify.Message{}
notify.Path = "file_operate"
notify.Msg = msg
NotifyMsg <- notify
return
}
listMsg := make(map[string]interface{})
model := notify.NotifyModel{}
model.State = "NORMAL"
list := []notify.File{}
OpStrArrbak := OpStrArr
@ -78,7 +93,9 @@ func (i *notifyServer) SendFileOperateNotify() {
} else {
task.Status = "PROCESSING"
}
if temp.ProcessedSize == temp.TotalSize {
if temp.ProcessedSize >= temp.TotalSize {
task.Finished = true
task.Status = "FINISHED"
FileQueue.Delete(v)
@ -109,8 +126,75 @@ func (i *notifyServer) SendFileOperateNotify() {
notify.Path = "file_operate"
notify.Msg = msg
NotifyMsg <- notify
time.Sleep(time.Second * 3)
} else {
for {
len := 0
FileQueue.Range(func(k, v interface{}) bool {
len++
return true
})
if len == 0 {
return
}
listMsg := make(map[string]interface{})
model := notify.NotifyModel{}
model.State = "NORMAL"
list := []notify.File{}
OpStrArrbak := OpStrArr
for _, v := range OpStrArrbak {
tempItem, ok := FileQueue.Load(v)
temp := tempItem.(model2.FileOperate)
if !ok {
continue
}
task := notify.File{}
task.Id = v
task.ProcessedSize = temp.ProcessedSize
task.TotalSize = temp.TotalSize
task.To = temp.To
task.Type = temp.Type
if task.ProcessedSize == 0 {
task.Status = "STARTING"
} else {
task.Status = "PROCESSING"
}
if temp.ProcessedSize >= temp.TotalSize {
task.Finished = true
task.Status = "FINISHED"
FileQueue.Delete(v)
OpStrArr = OpStrArr[1:]
go ExecOpFile()
list = append(list, task)
continue
}
for _, v := range temp.Item {
if v.Size != v.ProcessedSize {
task.ProcessingPath = v.From
break
}
}
list = append(list, task)
}
model.Data = list
listMsg["file_operate"] = model
msg := gosf.Message{}
msg.Success = true
msg.Body = listMsg
msg.Text = "file_operate"
notify := notify.Message{}
notify.Path = "file_operate"
notify.Msg = msg
NotifyMsg <- notify
time.Sleep(time.Second * 3)
}
}
}
func (i *notifyServer) SendPersonStatusBySocket(status notify.Person) {