Add local source publication
This commit is contained in:
31
internal/publish/reconcile.go
Normal file
31
internal/publish/reconcile.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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 {
|
||||
destinationState, parseErr := state.Parse(data)
|
||||
if parseErr != nil {
|
||||
return state.DestinationStatus{StateErr: parseErr}, nil
|
||||
}
|
||||
return state.DestinationStatus{State: &destinationState, HasContents: true}, nil
|
||||
}
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user