wip
Some checks failed
CloudSave/pipeline/head There was a failure building this commit

This commit is contained in:
2025-09-11 17:41:57 +02:00
parent d15de3c6a1
commit 5f7ca22b8f
5 changed files with 100 additions and 23 deletions

View File

@@ -2,8 +2,12 @@ package mainwindow
import (
"cloudsave/cmd/gui/window/about"
"cloudsave/cmd/gui/window/credential"
"cloudsave/cmd/gui/window/loading"
"cloudsave/pkg/data"
"cloudsave/pkg/remote"
"cloudsave/pkg/remote/client"
"cloudsave/pkg/sync"
"fmt"
"os"
"path/filepath"
@@ -103,9 +107,7 @@ func Make(a fyne.App, d *data.Service) fyne.Window {
}),
widget.NewToolbarSeparator(),
widget.NewToolbarAction(theme.UploadIcon(), func() {
go func() {
fmt.Println("todo")
}()
doSync(d, w)
}),
widget.NewToolbarSpacer(),
widget.NewToolbarAction(theme.HelpIcon(), func() {
@@ -118,3 +120,54 @@ func Make(a fyne.App, d *data.Service) fyne.Window {
w.SetContent(content)
return w
}
func doSync(d *data.Service, w fyne.Window) error {
remotes, err := remote.All()
if err != nil {
return err
}
i := 0
nextCh := make(chan struct{})
doneCh := make(chan struct{})
var cd *credential.CredentialDialog
go func() {
nextCh <- struct{}{}
}()
for {
select {
case <-doneCh:
return nil
case <-nextCh:
{
cd = credential.Make(remotes[i].URL, func(v bool) {
if !v {
return
}
username, password := cd.Credentials()
cli := client.New(remotes[i].URL, username, password)
sync.NewSyncer(cli, d)
fmt.Println(i)
if i < len(remotes) {
go func() {
nextCh <- struct{}{}
}()
} else {
go func() {
doneCh <- struct{}{}
}()
}
}, w)
cd.Show()
}
}
}
}