diff --git a/server/api_test.go b/server/api_test.go index 7a479a21..a56498c4 100644 --- a/server/api_test.go +++ b/server/api_test.go @@ -3,6 +3,8 @@ package server import ( "context" "fmt" + "os" + "path/filepath" "strconv" "testing" "time" @@ -236,12 +238,18 @@ func TestDeleteStream(t *testing.T) { err = client.CreateStream(context.Background(), "foo", "foo", lift.Partitions(3)) require.NoError(t, err) + _, err = os.Stat(filepath.Join(s1Config.DataDir, "streams", "foo")) + require.NoError(t, err) + stream := s1.metadata.GetStream("foo") require.NotNil(t, stream) err = client.DeleteStream(context.Background(), "foo") require.NoError(t, err) + _, err = os.Stat(filepath.Join(s1Config.DataDir, "streams", "foo")) + require.True(t, os.IsNotExist(err)) + stream = s1.metadata.GetStream("foo") require.Nil(t, stream) diff --git a/server/metadata.go b/server/metadata.go index 3cacbcef..38ff984a 100644 --- a/server/metadata.go +++ b/server/metadata.go @@ -835,9 +835,9 @@ func (m *metadataAPI) CloseAndDeleteStream(stream *stream) error { return errors.Wrap(err, "failed to delete stream") } - // Remove the (now empty) stream data directory + // Remove the stream data directory streamDataDir := filepath.Join(m.Server.config.DataDir, "streams", stream.GetName()) - err = os.Remove(streamDataDir) + err = os.RemoveAll(streamDataDir) if err != nil { return errors.Wrap(err, "failed to delete stream data directory") }