mirror of
https://github.com/wisplite/parchment.git
synced 2026-06-27 13:47:08 -05:00
Refactor UI state management and improve error handling in the application. Added success and error messages to enhance user feedback during package creation and device connection status updates.
This commit is contained in:
+9
-12
@@ -1,10 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"encoding/json"
|
||||
"io/fs"
|
||||
"strings"
|
||||
"log"
|
||||
)
|
||||
|
||||
type PackageJSON struct {
|
||||
@@ -35,39 +34,37 @@ func loadPackageJSON(fsys fs.FS) (*PackageJSON, error) {
|
||||
|
||||
func createCpkg(fsys fs.FS, pkgData *PackageJSON) (*cpkg, error) {
|
||||
pkg := NewCpkg(pkgData.Pkg)
|
||||
|
||||
|
||||
// Walk through all directories recursively
|
||||
err := fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
// Skip directories themselves (we only want files)
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// Skip certain files
|
||||
fileName := d.Name()
|
||||
if fileName == "debug.log" || strings.HasSuffix(fileName, ".cpkg") {
|
||||
log.Println("Skipping file:", path)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// Add file with full relative path
|
||||
log.Println("Adding file:", path)
|
||||
err = pkg.AddFile(fsys, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
success, err := pkg.Create()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -76,4 +73,4 @@ func createCpkg(fsys fs.FS, pkgData *PackageJSON) (*cpkg, error) {
|
||||
return nil, err
|
||||
}
|
||||
return pkg, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user