Clean the complete session run history
This commit is contained in:
@@ -138,52 +138,6 @@ func existingManagedView(parent *os.Root, name, category string) (*string, error
|
||||
return &target, nil
|
||||
}
|
||||
|
||||
// ManagedAttemptTargets returns run-relative diagnostic directories selected by
|
||||
// the session's managed navigation links. It never follows link targets.
|
||||
func ManagedAttemptTargets(sessionRoot, runID string, names []string) ([]string, error) {
|
||||
if err := pathsafe.ValidateOpaqueSegment(runID); err != nil {
|
||||
return nil, fmt.Errorf("run identity: %w", err)
|
||||
}
|
||||
root, err := os.OpenRoot(sessionRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer root.Close()
|
||||
var targets []string
|
||||
for _, category := range []string{"logs", "debug"} {
|
||||
info, err := root.Lstat(category)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !info.IsDir() || info.Mode()&os.ModeSymlink != 0 {
|
||||
return nil, fmt.Errorf("managed %s directory is unsafe", category)
|
||||
}
|
||||
parent, err := root.OpenRoot(category)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, name := range names {
|
||||
if err := pathsafe.ValidateOpaqueSegment(name); err != nil {
|
||||
_ = parent.Close()
|
||||
return nil, fmt.Errorf("invalid managed %s view %q: %w", category, name, err)
|
||||
}
|
||||
target, err := existingManagedView(parent, name, category)
|
||||
if err != nil {
|
||||
_ = parent.Close()
|
||||
return nil, err
|
||||
}
|
||||
if target != nil && *target == attemptTarget(runID, name, category) {
|
||||
targets = append(targets, filepath.Join(name, category))
|
||||
}
|
||||
}
|
||||
_ = parent.Close()
|
||||
}
|
||||
return targets, nil
|
||||
}
|
||||
|
||||
// InspectManagedAttemptViews reports whether any recognized managed view exists.
|
||||
// Dangling links count as present; their targets are never followed.
|
||||
func InspectManagedAttemptViews(sessionRoot string, names []string) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user