Skip to content

Commit

Permalink
inter
Browse files Browse the repository at this point in the history
  • Loading branch information
SudhanshuBawane committed Jan 23, 2024
1 parent 8eb5e0e commit 145a140
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion agent/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"time"

"github.com/sensu/sensu-go/agent"
corev2 "github.com/sensu/core/v2"
"github.com/sensu/sensu-go/agent"
"github.com/sensu/sensu-go/asset"
"github.com/sensu/sensu-go/util/path"
"github.com/sensu/sensu-go/util/url"
Expand Down
18 changes: 14 additions & 4 deletions asset/boltdb_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
sensupath "github.com/sensu/sensu-go/util/path"
"github.com/spf13/viper"
"os"
"path/filepath"

Expand All @@ -24,6 +24,7 @@ const (
// ExpandDuration is the name of the prometheus summary vec used to track
// average latencies of asset expansion.
ExpandDuration = "sensu_go_asset_expand_duration"
FlagCacheDir = "cache-dir"
)

var (
Expand Down Expand Up @@ -186,6 +187,7 @@ func (b *boltDBAssetManager) Get(ctx context.Context, asset *corev2.Asset) (*Run

// verify
if err := b.verifier.Verify(tmpFile, asset.Sha512); err != nil {

logger.Println("=====SUDHANSHU File size verifier call return 4 =======", err)
logger.Println(bucket, "========info========")
// Attempt to retrieve the size of the downloaded asset
Expand Down Expand Up @@ -259,10 +261,18 @@ func (b *boltDBAssetManager) expandWithDuration(tmpFile *os.File, asset *corev2.
Observe(v * float64(1000))
}))
defer timer.ObserveDuration()
aseetSHA := asset.Sha512
fullPath := "/home/raiden/Desktop/sensu/agent/cache/" + aseetSHA
assetSHA := asset.Sha512
//fullPath := "/home/raiden/Desktop/sensu/agent/cache/" + assetSHA

//cfg := agent.NewConfig()
//viper.SetDefault(FlagCacheDir, path.SystemCacheDir("sensu-agent"))
CacheDir := viper.GetString(FlagCacheDir)
fullPath := filepath.Join(CacheDir, assetSHA)
errorSHA := os.RemoveAll(fullPath)
logger.Println("=====cache dir =========", sensupath.UserCacheDir("sensuctl"))
logger.Println()

//logger.Println("=====cache dir =========", sensupath.UserCacheDir("sensuctl"))
logger.Println("======= cache dir=========", CacheDir, fullPath)
logger.Println("========== SHA Error is =====================", errorSHA)
logger.Println()
assetPath = filepath.Join(b.localStorage, asset.Sha512)
Expand Down

0 comments on commit 145a140

Please sign in to comment.