Skip to content

Commit

Permalink
pass chunk name in storage data
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic committed Dec 19, 2023
1 parent b75c2f0 commit f0bb1ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 8 additions & 6 deletions pkg/storage/utils/decomposedfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ func (fs *Decomposedfs) Upload(ctx context.Context, req storage.UploadRequest, u

session := up.(*upload.OcisSession)

p := session.Filename()
if chunking.IsChunked(p) { // check chunking v1
var assembledFile string
p, assembledFile, err = fs.chunkHandler.WriteChunk(p, req.Body)
if session.Chunk() != "" { // check chunking v1
p, assembledFile, err := fs.chunkHandler.WriteChunk(session.Chunk(), req.Body)
if err != nil {
return provider.ResourceInfo{}, err
}
Expand All @@ -67,7 +65,6 @@ func (fs *Decomposedfs) Upload(ctx context.Context, req storage.UploadRequest, u
}
return provider.ResourceInfo{}, errtypes.PartialContent(req.Ref.String())
}
session.SetStorageValue("NodeName", p)
fd, err := os.Open(assembledFile)
if err != nil {
return provider.ResourceInfo{}, errors.Wrap(err, "Decomposedfs: error opening assembled file")
Expand Down Expand Up @@ -125,8 +122,10 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere

// remember the path from the reference
refpath := ref.GetPath()
var chunk *chunking.ChunkBLOBInfo
var err error
if chunking.IsChunked(refpath) { // check chunking v1
chunk, err := chunking.GetChunkBLOBInfo(refpath)
chunk, err = chunking.GetChunkBLOBInfo(refpath)
if err != nil {
return nil, errtypes.BadRequest(err.Error())
}
Expand Down Expand Up @@ -158,6 +157,9 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere
session := fs.sessionStore.New(ctx)
session.SetMetadata("filename", n.Name)
session.SetStorageValue("NodeName", n.Name)
if chunk != nil {
session.SetStorageValue("Chunk", filepath.Base(refpath))
}
session.SetMetadata("dir", filepath.Dir(relative))
session.SetStorageValue("Dir", filepath.Dir(relative))
session.SetMetadata("lockid", lockID)
Expand Down
4 changes: 3 additions & 1 deletion pkg/storage/utils/decomposedfs/upload/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ func (m *OcisSession) ID() string {
func (m *OcisSession) Filename() string {
return m.info.Storage["NodeName"]
}

func (m *OcisSession) Chunk() string {
return m.info.Storage["Chunk"]
}
func (m *OcisSession) SetMetadata(key, value string) {
m.info.MetaData[key] = value
}
Expand Down

0 comments on commit f0bb1ea

Please sign in to comment.