refactor(plugin): use flat file system for loopback storage

pull/3251/head
Damian Debkowski 3 years ago committed by Timothy Messier
parent 4387a59ce5
commit 234c4ade86
No known key found for this signature in database
GPG Key ID: EFD2F184F7600572

@ -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

@ -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",
})

Loading…
Cancel
Save