mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-19 09:40:12 +00:00
fix(agentcompat): root workspace log creation
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/nezhahq/nezha/integration/agentcompat/internal/evidence"
|
"github.com/nezhahq/nezha/integration/agentcompat/internal/evidence"
|
||||||
@@ -27,7 +28,12 @@ type LogFile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newLogFile(path string, maxBytes int) (*LogFile, error) {
|
func newLogFile(path string, maxBytes int) (*LogFile, error) {
|
||||||
file, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o600)
|
root, err := os.OpenRoot(filepath.Dir(path))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("open workspace log directory: %w", err)
|
||||||
|
}
|
||||||
|
defer root.Close()
|
||||||
|
file, err := root.OpenFile(filepath.Base(path), os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("create workspace log: %w", err)
|
return nil, fmt.Errorf("create workspace log: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user