Added tentacle updater.

This commit is contained in:
Kendell Clark authored and Storm Dragon committed 2026-11-01 12:21:55 -05:00
1 parent f2cc47c8a0
commit 7591f65b58
17 files changed
+948 -22

No files matched your search

+56
View File
@@ -212,6 +212,62 @@ func (page *tentaclePage) action(action int) (*tentacle.ManagementRequest, error
return nil, errors.New("Select a tentacle first.")
}
page.selectedKey = selected.key
if action == 21 {
if !selected.installed {
return nil, errors.New("Install this tentacle first.")
}
entry := selected.status.Entry
for _, update := range page.snapshot.Updates {
if update.ID != entry.ID {
continue
}
permissions := ""
foundManifest := false
for _, repository := range page.snapshot.Repositories {
if repository.URL != update.RepositoryURL || repository.ID != update.RepositoryID {
continue
}
for _, manifest := range repository.Tentacles {
if manifest.ID != update.LocalID {
continue
}
foundManifest = true
var previous []string
if entry.Presentation {
previous = append(previous, "presentation")
}
if entry.Interaction {
previous = append(previous, "interaction")
}
if entry.ReaderSettings {
previous = append(previous, "reader-settings")
}
if len(previous) == 0 {
previous = append(previous, "none")
}
declared := manifest.Capabilities
if len(declared) == 0 {
declared = []string{"none"}
}
permissions = "Current capabilities: " + strings.Join(previous, ", ") +
". Repository declares: " + strings.Join(declared, ", ") + "."
}
}
if !foundManifest {
return nil, errors.New("Updated package manifest is unavailable; refresh the repository before upgrading.")
}
message := fmt.Sprintf("Update %s from version %s to version %s?\n\n%s\n\nOnly update packages from publishers you trust. Tentacles run with your account's access.\n\nChanges take effect immediately.", update.Name, update.InstalledVersion, update.AvailableVersion, permissions)
text, button := C.CString(message), C.CString("Update")
accepted := C.prefs_tentacle_confirm(text, button)
C.free(unsafe.Pointer(text))
C.free(unsafe.Pointer(button))
if accepted == 0 {
return nil, nil
}
return &tentacle.ManagementRequest{Action: "upgrade", ID: update.LocalID, URL: update.RepositoryURL}, nil
}
return nil, errors.New("No newer version is available for the selected tentacle. Refresh its repository to check again.")
}
if !selected.installed {
if action != 11 && action != 19 {
return nil, errors.New("Install this tentacle first.")