Skip to content

Commit

Permalink
chore: Update disk usage display and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
i5heu committed May 8, 2024
1 parent d604cc6 commit 1aacf8f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
tmp/*
data/*
benchmarks/*
ExamplePath/*
*.txt
*.log
*.out
Expand Down
10 changes: 10 additions & 0 deletions internal/keyValStore/spaceInformations.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ func contains(path, mountpoint string) bool {
// displayDiskUsage displays the disk usage information using structured logging
func displayDiskUsage(paths []string) error {

if len(paths) == 0 {
log.Error("No path provided in configuration")
return fmt.Errorf("no path provided in configuration")
}

if paths[0] == "ExamplePath" {
return nil

}

for _, path := range paths {
disk, err := getDiskUsageStats(path)
if err != nil {
Expand Down
12 changes: 7 additions & 5 deletions ouroboros_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ func Test_DB_CreateNewEvent(t *testing.T) {
func Example() {
// Initialize OuroborosDB with basic configuration
ou, err := ouroboros.NewOuroborosDB(ouroboros.Config{
Paths: []string{"/root/data"}, // Directory for data storage
MinimumFreeGB: 1, // Minimum free space in GB
GarbageCollectionInterval: 10, // GC interval in seconds
Paths: []string{"ExamplePath"}, // Directory for data storage
MinimumFreeGB: 1, // Minimum free space in GB
GarbageCollectionInterval: 10, // GC interval in seconds
})
if err != nil {
log.Fatal(fmt.Sprintf("Failed to initialize OuroborosDB: %s", err))
Expand All @@ -441,8 +441,10 @@ func Example() {
log.Fatal(fmt.Sprintf("Error rebuilding index: %s", err))
}

uniqueNameBypass := time.Now().String()

// Create a root event titled "ExampleRoot"
rootEvent, err := ou.DB.CreateRootEvent("ExampleRoot")
rootEvent, err := ou.DB.CreateRootEvent("ExampleRoot" + uniqueNameBypass)
if err != nil {
log.Fatal(fmt.Sprintf("Error creating root event: %s", err))
}
Expand All @@ -463,7 +465,7 @@ func Example() {
}

// Retrieve root events with the title "ExampleRoot"
rootEvents, err := ou.DB.GetRootEventsWithTitle("ExampleRoot")
rootEvents, err := ou.DB.GetRootEventsWithTitle("ExampleRoot" + uniqueNameBypass)
if err != nil {
log.Fatal(fmt.Sprintf("Error retrieving root events: %s", err))
}
Expand Down

0 comments on commit 1aacf8f

Please sign in to comment.