Skip to content

fix(cmd): add missing defer db.Close(), fix uncheked errors - #74

Merged
kavix merged 4 commits into
kavix:mainfrom
vomar3:main
Jul 29, 2026
Merged

fix(cmd): add missing defer db.Close(), fix uncheked errors#74
kavix merged 4 commits into
kavix:mainfrom
vomar3:main

Conversation

@vomar3

@vomar3 vomar3 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Fixed #73

@vomar3

vomar3 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

I noticed that error checking isn't implemented everywhere for example, here

cmd/restore.go:

Run: func(cmd *cobra.Command, args []string) {
		os.MkdirAll(".eko/snapshots", 0755)
		database := db.InitDB()
		defer database.Close()
		database.Exec(`
			CREATE TABLE IF NOT EXISTS snapshots (
				id TEXT PRIMARY KEY,
				message TEXT,
				path TEXT,
				created_at DATETIME DEFAULT CURRENT_TIMESTAMP
			)
		`)
		fmt.Println("Eko initialized.")

		// Check if a .git directory exists
		if info, err := os.Stat(".git"); err == nil && info.IsDir() {
			fmt.Println("Tip: A Git repository was detected. Eko runs independently of Git but automatically ignores the .git directory.")
		}
	},

So, I can replace Run with RunE and return an error here and in other places in the code.

@kavix
kavix merged commit 35f9132 into kavix:main Jul 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmd: DB handle leak and unchecked Scan errors in restore/history

2 participants