refactor(plugin): use flat file system for loopback storage
This commit is contained in:
1 parent
4387a59ce5
commit
234c4ade86
2 files changed
-25
No files matched your search
@@ -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",
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user