Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Feb 5, 2025
1 parent 827bf2a commit 1497ea0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lxd/storage/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package storage

import (
"context"
"crypto/sha256"
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -268,6 +270,18 @@ func VolumeDBCreate(pool Pool, projectName string, volumeName string, volumeDesc
// Set source indicator.
vol.SetHasSource(hasSource)

bytes, _ := json.Marshal(vol.Config()) // Convert map to JSON
old := sha256.Sum256(bytes)

pool.Driver().FillVolumeConfig(vol)

bytes, _ = json.Marshal(vol.Config()) // Convert map to JSON
newHash := sha256.Sum256(bytes)

if old != newHash {
return errors.New("Volume fill not previously performed")
}

// Validate config.
err = pool.Driver().ValidateVolume(vol, removeUnknownKeys)
if err != nil {
Expand Down

0 comments on commit 1497ea0

Please sign in to comment.