Files

36 lines
1006 B
Go
Raw Permalink Normal View History

2026-05-31 02:21:36 +00:00
package publish
import (
"context"
"gitea.maximumdirect.net/eric/distributor/internal/state"
"gitea.maximumdirect.net/eric/distributor/internal/storage"
)
func inspectDestination(ctx context.Context, backend storage.Backend, bundlePath string) (state.DestinationStatus, error) {
statePath, err := storage.StatePath(bundlePath)
if err != nil {
return state.DestinationStatus{}, err
}
data, err := backend.ReadFile(ctx, statePath)
if err == nil {
2026-06-08 18:53:22 +00:00
document, parseErr := state.ParseDocument(data)
2026-05-31 02:21:36 +00:00
if parseErr != nil {
return state.DestinationStatus{StateErr: parseErr}, nil
}
2026-06-19 15:28:03 +00:00
return state.DestinationStatus{
Catalog: document.Catalog,
SupersededLegacy: document.SupersededLegacy,
HasContents: true,
}, nil
2026-05-31 02:21:36 +00:00
}
if !storage.IsNotFound(err) {
return state.DestinationStatus{}, err
}
hasContents, err := backend.HasAny(ctx, bundlePath)
if err != nil {
return state.DestinationStatus{}, err
}
return state.DestinationStatus{HasContents: hasContents}, nil
}