From 234c4ade8650e2439f35058fbc0d19845274ffe2 Mon Sep 17 00:00:00 2001 From: Damian Debkowski Date: Wed, 17 May 2023 15:21:26 -0700 Subject: [PATCH] refactor(plugin): use flat file system for loopback storage --- internal/plugin/loopback/storage.go | 15 --------------- internal/plugin/loopback/storage_test.go | 10 ---------- 2 files changed, 25 deletions(-) diff --git a/internal/plugin/loopback/storage.go b/internal/plugin/loopback/storage.go index 07934474b1..19a1ff1582 100644 --- a/internal/plugin/loopback/storage.go +++ b/internal/plugin/loopback/storage.go @@ -7,11 +7,9 @@ import ( "bytes" "context" "crypto/sha256" - "fmt" "io" "os" "path" - "strings" "sync" "time" @@ -358,19 +356,6 @@ func (l *LoopbackStorage) putObject(ctx context.Context, req *plgpb.PutObjectReq } contentLength := int64(len(objectData)) - parts := strings.Split(req.GetKey(), "/") - tempPath := req.GetBucket().GetBucketPrefix() - for _, p := range parts[:len(parts)-1] { - // Directories should have trailing `/` in the key - tempPath = fmt.Sprintf("%v%v/", tempPath, p) - emptyContent := int64(0) - bucket[ObjectName(tempPath)] = &storagePluginStorageInfo{ - lastModified: &lastModified, - contentLength: &emptyContent, - DataChunks: []Chunk{}, - } - } - objectChunks := []Chunk{} for i := 0; i < len(objectData); i = i + l.chunksSize { j := i + l.chunksSize diff --git a/internal/plugin/loopback/storage_test.go b/internal/plugin/loopback/storage_test.go index 5c9948bc51..3b465cd0f8 100644 --- a/internal/plugin/loopback/storage_test.go +++ b/internal/plugin/loopback/storage_test.go @@ -1001,17 +1001,7 @@ func TestLoopbackStoragePlugin(t *testing.T) { require.NoError(err) assert.EqualValues(hash.Sum(nil), putResponse.GetChecksumSha_256()) - // Check directory was created headResponse, err := plg.HeadObject(context.Background(), &plgpb.HeadObjectRequest{ - Bucket: bucket, - Key: "dir1/", - }) - require.NoError(err) - require.NotNil(headResponse) - require.NotNil(headResponse.LastModified) - require.Equal(int64(0), headResponse.ContentLength) - - headResponse, err = plg.HeadObject(context.Background(), &plgpb.HeadObjectRequest{ Bucket: bucket, Key: "dir1/mock_object", })