细化进度条的显示
This commit is contained in:
parent
9c9d740bb0
commit
911efd41dd
2
app.go
2
app.go
@ -18,7 +18,7 @@ const (
|
|||||||
defaultConfig = "config"
|
defaultConfig = "config"
|
||||||
configDefaultUserKey = "userConfig.defaultUser"
|
configDefaultUserKey = "userConfig.defaultUser"
|
||||||
configUsersKey = "userConfig.users"
|
configUsersKey = "userConfig.users"
|
||||||
appVersion = "v1.0.0"
|
appVersion = "v1.0.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// App struct
|
// App struct
|
||||||
|
File diff suppressed because one or more lines are too long
2
frontend/dist/index.html
vendored
2
frontend/dist/index.html
vendored
@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||||
<title>wechatDataBackup</title>
|
<title>wechatDataBackup</title>
|
||||||
<script type="module" crossorigin src="/assets/index.beba636e.js"></script>
|
<script type="module" crossorigin src="/assets/index.54b86a81.js"></script>
|
||||||
<link rel="stylesheet" href="/assets/index.de7292ad.css">
|
<link rel="stylesheet" href="/assets/index.de7292ad.css">
|
||||||
</head>
|
</head>
|
||||||
<body >
|
<body >
|
||||||
|
@ -16,6 +16,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"wechatDataBackup/pkg/lame"
|
"wechatDataBackup/pkg/lame"
|
||||||
"wechatDataBackup/pkg/silk"
|
"wechatDataBackup/pkg/silk"
|
||||||
@ -82,8 +84,21 @@ func exportWeChatVoice(info WeChatInfo, expPath string, progress chan<- string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleNumber := int64(0)
|
||||||
|
fileNumber := int64(0)
|
||||||
|
index := 0
|
||||||
|
for {
|
||||||
|
mediaMSGDB := fmt.Sprintf("%s\\Msg\\Multi\\MediaMSG%d.db", expPath, index)
|
||||||
|
_, err := os.Stat(mediaMSGDB)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
index += 1
|
||||||
|
fileNumber += 1
|
||||||
|
}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
index := -1
|
index = -1
|
||||||
MSGChan := make(chan wechatMediaMSG, 100)
|
MSGChan := make(chan wechatMediaMSG, 100)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@ -117,6 +132,7 @@ func exportWeChatVoice(info WeChatInfo, expPath string, progress chan<- string)
|
|||||||
|
|
||||||
MSGChan <- msg
|
MSGChan <- msg
|
||||||
}
|
}
|
||||||
|
atomic.AddInt64(&handleNumber, 1)
|
||||||
}
|
}
|
||||||
close(MSGChan)
|
close(MSGChan)
|
||||||
}()
|
}()
|
||||||
@ -139,6 +155,22 @@ func exportWeChatVoice(info WeChatInfo, expPath string, progress chan<- string)
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
for {
|
||||||
|
if handleNumber >= fileNumber {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
filePercent := float64(handleNumber) / float64(fileNumber)
|
||||||
|
totalPercent := 61 + (filePercent * (100 - 61))
|
||||||
|
totalPercentStr := fmt.Sprintf("{\"status\":\"processing\", \"result\":\"export WeChat voice doing\", \"progress\": %d}", int(totalPercent))
|
||||||
|
progress <- totalPercentStr
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat voice end\", \"progress\": 100}"
|
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat voice end\", \"progress\": 100}"
|
||||||
}
|
}
|
||||||
@ -149,6 +181,14 @@ func exportWeChatVideoAndFile(info WeChatInfo, expPath string, progress chan<- s
|
|||||||
fileRootPath := info.FilePath + "\\FileStorage\\File"
|
fileRootPath := info.FilePath + "\\FileStorage\\File"
|
||||||
cacheRootPath := info.FilePath + "\\FileStorage\\Cache"
|
cacheRootPath := info.FilePath + "\\FileStorage\\Cache"
|
||||||
rootPaths := []string{videoRootPath, fileRootPath, cacheRootPath}
|
rootPaths := []string{videoRootPath, fileRootPath, cacheRootPath}
|
||||||
|
|
||||||
|
handleNumber := int64(0)
|
||||||
|
fileNumber := int64(0)
|
||||||
|
for _, path := range rootPaths {
|
||||||
|
fileNumber += getPathFileNumber(path, "")
|
||||||
|
}
|
||||||
|
log.Println("VideoAndFile ", fileNumber)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
taskChan := make(chan [2]string, 100)
|
taskChan := make(chan [2]string, 100)
|
||||||
go func() {
|
go func() {
|
||||||
@ -167,10 +207,6 @@ func exportWeChatVideoAndFile(info WeChatInfo, expPath string, progress chan<- s
|
|||||||
os.MkdirAll(filepath.Dir(expFile), 0644)
|
os.MkdirAll(filepath.Dir(expFile), 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Stat(expFile)
|
|
||||||
if err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
task := [2]string{path, expFile}
|
task := [2]string{path, expFile}
|
||||||
taskChan <- task
|
taskChan <- task
|
||||||
return nil
|
return nil
|
||||||
@ -191,14 +227,34 @@ func exportWeChatVideoAndFile(info WeChatInfo, expPath string, progress chan<- s
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for task := range taskChan {
|
for task := range taskChan {
|
||||||
_, err := copyFile(task[0], task[1])
|
_, err := os.Stat(task[1])
|
||||||
|
if err == nil {
|
||||||
|
atomic.AddInt64(&handleNumber, 1)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
_, err = copyFile(task[0], task[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("DecryptDat:", err)
|
log.Println("DecryptDat:", err)
|
||||||
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"copyFile %v\"}", err)
|
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"copyFile %v\"}", err)
|
||||||
}
|
}
|
||||||
|
atomic.AddInt64(&handleNumber, 1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
for {
|
||||||
|
if handleNumber >= fileNumber {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
filePercent := float64(handleNumber) / float64(fileNumber)
|
||||||
|
totalPercent := 41 + (filePercent * (60 - 41))
|
||||||
|
totalPercentStr := fmt.Sprintf("{\"status\":\"processing\", \"result\":\"export WeChat Video and File doing\", \"progress\": %d}", int(totalPercent))
|
||||||
|
progress <- totalPercentStr
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat Video and File end\", \"progress\": 60}"
|
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat Video and File end\", \"progress\": 60}"
|
||||||
}
|
}
|
||||||
@ -212,6 +268,8 @@ func exportWeChatBat(info WeChatInfo, expPath string, progress chan<- string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleNumber := int64(0)
|
||||||
|
fileNumber := getPathFileNumber(datRootPath, ".dat")
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
taskChan := make(chan [2]string, 100)
|
taskChan := make(chan [2]string, 100)
|
||||||
go func() {
|
go func() {
|
||||||
@ -228,11 +286,6 @@ func exportWeChatBat(info WeChatInfo, expPath string, progress chan<- string) {
|
|||||||
os.MkdirAll(filepath.Dir(expFile), 0644)
|
os.MkdirAll(filepath.Dir(expFile), 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Stat(expFile)
|
|
||||||
if err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
task := [2]string{path, expFile}
|
task := [2]string{path, expFile}
|
||||||
taskChan <- task
|
taskChan <- task
|
||||||
return nil
|
return nil
|
||||||
@ -253,14 +306,35 @@ func exportWeChatBat(info WeChatInfo, expPath string, progress chan<- string) {
|
|||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for task := range taskChan {
|
for task := range taskChan {
|
||||||
|
_, err = os.Stat(task[1])
|
||||||
|
if err == nil {
|
||||||
|
atomic.AddInt64(&handleNumber, 1)
|
||||||
|
continue
|
||||||
|
}
|
||||||
err = DecryptDat(task[0], task[1])
|
err = DecryptDat(task[0], task[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("DecryptDat:", err)
|
log.Println("DecryptDat:", err)
|
||||||
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"DecryptDat %v\"}", err)
|
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"DecryptDat %v\"}", err)
|
||||||
}
|
}
|
||||||
|
atomic.AddInt64(&handleNumber, 1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
for {
|
||||||
|
if handleNumber >= fileNumber {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
filePercent := float64(handleNumber) / float64(fileNumber)
|
||||||
|
totalPercent := 21 + (filePercent * (40 - 21))
|
||||||
|
totalPercentStr := fmt.Sprintf("{\"status\":\"processing\", \"result\":\"export WeChat Dat doing\", \"progress\": %d}", int(totalPercent))
|
||||||
|
progress <- totalPercentStr
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat Dat end\", \"progress\": 40}"
|
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat Dat end\", \"progress\": 40}"
|
||||||
}
|
}
|
||||||
@ -276,6 +350,8 @@ func exportWeChatDateBase(info WeChatInfo, expPath string, progress chan<- strin
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleNumber := int64(0)
|
||||||
|
fileNumber := getPathFileNumber(info.FilePath+"\\Msg", ".db")
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
taskChan := make(chan [2]string, 20)
|
taskChan := make(chan [2]string, 20)
|
||||||
go func() {
|
go func() {
|
||||||
@ -318,9 +394,25 @@ func exportWeChatDateBase(info WeChatInfo, expPath string, progress chan<- strin
|
|||||||
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"%s %v\"}", task[0], err)
|
progress <- fmt.Sprintf("{\"status\":\"error\", \"result\":\"%s %v\"}", task[0], err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
atomic.AddInt64(&handleNumber, 1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
for {
|
||||||
|
if handleNumber >= fileNumber {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
filePercent := float64(handleNumber) / float64(fileNumber)
|
||||||
|
totalPercent := 1 + (filePercent * (20 - 1))
|
||||||
|
totalPercentStr := fmt.Sprintf("{\"status\":\"processing\", \"result\":\"export WeChat DateBase doing\", \"progress\": %d}", int(totalPercent))
|
||||||
|
progress <- totalPercentStr
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
}()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat DateBase end\", \"progress\": 20}"
|
progress <- "{\"status\":\"processing\", \"result\":\"export WeChat DateBase end\", \"progress\": 20}"
|
||||||
return true
|
return true
|
||||||
@ -651,3 +743,24 @@ func silkToMp3(amrBuf []byte, mp3Path string) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPathFileNumber(targetPath string, fileSuffix string) int64 {
|
||||||
|
|
||||||
|
number := int64(0)
|
||||||
|
err := filepath.Walk(targetPath, func(path string, finfo os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("filepath.Walk:%v\n", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !finfo.IsDir() && strings.HasSuffix(path, fileSuffix) {
|
||||||
|
number += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Println("filepath.Walk:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return number
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user