Skip to content

Commit

Permalink
close should also handle case when DB is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
heavycrystal committed Dec 5, 2023
1 parent 72d93a6 commit 0fb606a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions flow/connectors/utils/cdc_records/cdc_records_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,13 @@ func (c *cdcRecordsStore) Len() int {

func (c *cdcRecordsStore) Close() error {
c.inMemoryRecords = nil
err := c.pebbleDB.Close()
if err != nil {
return fmt.Errorf("failed to close database: %w", err)
if c.pebbleDB != nil {
err := c.pebbleDB.Close()
if err != nil {
return fmt.Errorf("failed to close database: %w", err)
}
}
err = os.RemoveAll(c.dbFolderName)
err := os.RemoveAll(c.dbFolderName)
if err != nil {
return fmt.Errorf("failed to delete database file: %w", err)
}
Expand Down

0 comments on commit 0fb606a

Please sign in to comment.