Keep one verified copy of session audio
This commit is contained in:
@@ -2,13 +2,10 @@ package stage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/fileops"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||
)
|
||||
|
||||
@@ -20,10 +17,8 @@ const (
|
||||
type cleanupStage struct{}
|
||||
|
||||
type cleanupSemanticConfig struct {
|
||||
DeleteSpoolAudio bool `json:"delete_spool_audio"`
|
||||
SpoolRoot string `json:"spool_root"`
|
||||
DeleteWorkspace bool `json:"delete_workspace"`
|
||||
WorkspaceRoot string `json:"workspace_root"`
|
||||
DeleteWorkspace bool `json:"delete_workspace"`
|
||||
WorkspaceRoot string `json:"workspace_root"`
|
||||
}
|
||||
|
||||
func (cleanupStage) Name() string { return "cleanup" }
|
||||
@@ -47,12 +42,7 @@ func (cleanupStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*S
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, fmt.Errorf("cleanup canceled before %s: %w", target.policy, err)
|
||||
}
|
||||
var err error
|
||||
if target.policy == cleanupWorkspacePolicy {
|
||||
_, err = cleanRunWithRetainedBundle(target.root, target.target, true)
|
||||
} else {
|
||||
err = fileops.RemoveAllUnderRoot(target.root, target.target)
|
||||
}
|
||||
_, err := cleanRunWithRetainedBundle(target.root, target.target, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("apply %s: %w", target.policy, err)
|
||||
}
|
||||
@@ -72,10 +62,8 @@ func (cleanupStage) SemanticConfigFingerprint(env *Env) (manifest.SemanticConfig
|
||||
}
|
||||
pipeline := env.Config.Pipeline
|
||||
return FingerprintSemanticConfig(cleanupSemanticConfigVersion, cleanupSemanticConfig{
|
||||
DeleteSpoolAudio: pipeline.Spool.DeleteAudioAfterPublish,
|
||||
SpoolRoot: normalizedCleanupRoot(pipeline.Spool.Root),
|
||||
DeleteWorkspace: pipeline.Workspace.CleanupAfterPublish,
|
||||
WorkspaceRoot: normalizedCleanupRoot(pipeline.Workspace.Root),
|
||||
DeleteWorkspace: pipeline.Workspace.CleanupAfterPublish,
|
||||
WorkspaceRoot: normalizedCleanupRoot(pipeline.Workspace.Root),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -91,20 +79,12 @@ func (cleanupStage) ValidateResume(ctx context.Context, env *Env, m *manifest.Ma
|
||||
if err := ctx.Err(); err != nil {
|
||||
return ResumeValidation{}, fmt.Errorf("validate cleanup resume for %s: %w", target.policy, err)
|
||||
}
|
||||
if target.policy == cleanupWorkspacePolicy {
|
||||
pending, err := cleanRunWithRetainedBundle(target.root, target.target, false)
|
||||
if err != nil {
|
||||
return ResumeValidation{}, err
|
||||
}
|
||||
if pending {
|
||||
return NonResumable(fmt.Sprintf("cleanup target for %s exists", target.policy)), nil
|
||||
}
|
||||
continue
|
||||
pending, err := cleanRunWithRetainedBundle(target.root, target.target, false)
|
||||
if err != nil {
|
||||
return ResumeValidation{}, err
|
||||
}
|
||||
if _, err := os.Lstat(target.target); err == nil {
|
||||
if pending {
|
||||
return NonResumable(fmt.Sprintf("cleanup target for %s exists", target.policy)), nil
|
||||
} else if !errors.Is(err, os.ErrNotExist) {
|
||||
return ResumeValidation{}, fmt.Errorf("inspect cleanup target for %s: %w", target.policy, err)
|
||||
}
|
||||
}
|
||||
return Resumable(), nil
|
||||
|
||||
Reference in New Issue
Block a user