From f44494d2bb383609e9ce027884725cc9a9906246 Mon Sep 17 00:00:00 2001 From: ehsan shariati Date: Wed, 21 Feb 2024 19:23:00 -0500 Subject: [PATCH] Update main.go --- modules/initipfs/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/initipfs/main.go b/modules/initipfs/main.go index aff55b0..7100c78 100644 --- a/modules/initipfs/main.go +++ b/modules/initipfs/main.go @@ -141,7 +141,11 @@ func readIPFSConfig(path string) (IPFSConfig, error) { } else { // Unmarshal only if the file has content if err := json.Unmarshal(data, &cfg); err != nil { - panic(fmt.Sprintf("Failed to unmarshal IPFS config: %v", err)) + // Unmarshaling failed, replace file with empty one and return empty cfg + if err := createEmptyFile(path); err != nil { + return cfg, err + } + return cfg, nil } } return cfg, nil