From 05739d0b9f5be0d6e87a8f22cb433ecd3dca7cd9 Mon Sep 17 00:00:00 2001 From: mlycore Date: Mon, 18 Dec 2023 11:20:14 +0800 Subject: [PATCH] feat: create directory before check Signed-off-by: mlycore --- pitr/agent/internal/handler/diskspace.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pitr/agent/internal/handler/diskspace.go b/pitr/agent/internal/handler/diskspace.go index 401d523c..b9807f9a 100644 --- a/pitr/agent/internal/handler/diskspace.go +++ b/pitr/agent/internal/handler/diskspace.go @@ -40,6 +40,10 @@ func DiskSpace(ctx *fiber.Ctx) error { return fmt.Errorf("invalid parameter, err wrap: %w", err) } + if err := os.MkdirAll(in.DiskPath, 0755); err != nil { + return fmt.Errorf("mkdir [%s] failure, err wrap: %w", in.DiskPath, err) + } + // show disk space cmd := fmt.Sprintf("df -h %s", in.DiskPath) output, err := cmds.Exec(os.Getenv("SHELL"), cmd)