Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions pkg/simplecontent/service_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,21 @@ func (s *service) UploadDerivedContent(ctx context.Context, req UploadDerivedCon
}
}

// Step 7: Upload the data
// Step 7: Create object metadata
objectMetadata := &ObjectMetadata{
ObjectID: objectID,
CreatedAt: now,
UpdatedAt: now,
}
if err := s.repository.SetObjectMetadata(ctx, objectMetadata); err != nil {
return nil, &ObjectError{
ObjectID: objectID,
Op: "upload_object_metadata_create",
Err: err,
}
}

// Step 8: Upload the data
backend, err := s.GetBackend(storageBackend)
if err != nil {
return nil, &ObjectError{ObjectID: objectID, Op: "upload_derived_get_backend", Err: err}
Expand All @@ -740,14 +754,20 @@ func (s *service) UploadDerivedContent(ctx context.Context, req UploadDerivedCon
return nil, &ObjectError{ObjectID: objectID, Op: "upload_derived_data", Err: err}
}

// Step 8: Update object status
// Step 9: Update object status
object.Status = string(ObjectStatusUploaded)
if err := s.repository.UpdateObject(ctx, object); err != nil {
return nil, &ObjectError{ObjectID: objectID, Op: "upload_derived_update_status", Err: err}
}

// Step 9: Create content metadata if provided
if req.FileName != "" || req.FileSize > 0 || len(req.Tags) > 0 {
// Step 10: Update object metadata
object_metadata, err := s.updateObjectFromStorage(ctx, objectID)
if err != nil {
// Log warning but don't fail - object was uploaded successfully
}

// Step 11: Create content metadata if provided
if req.FileName != "" || len(req.Tags) > 0 {
metadata := &ContentMetadata{
ContentID: content.ID,
FileName: req.FileName,
Expand All @@ -757,6 +777,10 @@ func (s *service) UploadDerivedContent(ctx context.Context, req UploadDerivedCon
CreatedAt: now,
UpdatedAt: now,
}
if object_metadata != nil {
metadata.FileSize = object_metadata.SizeBytes
metadata.MimeType = object_metadata.MimeType
}
if metadata.Metadata == nil {
metadata.Metadata = make(map[string]interface{})
}
Expand All @@ -766,7 +790,7 @@ func (s *service) UploadDerivedContent(ctx context.Context, req UploadDerivedCon
}
}

// Step 10: Update content status to processed
// Step 12: Update content status to processed
// Derived content is set to "processed" (not "uploaded") because derived content
// IS the output of processing - once uploaded, it's immediately ready to serve.
// Original content uses "uploaded" status, derived content uses "processed" status.
Expand Down Expand Up @@ -2008,7 +2032,6 @@ func (s *service) GetContentDetailsBatch(ctx context.Context, contentIDs []uuid.
return result, nil
}


Comment thread
sgao640 marked this conversation as resolved.
// computeDerivationDepth computes the derivation depth by recursively traversing the parent chain
// Maximum depth is capped at 100 to prevent infinite loops
func (s *service) computeDerivationDepth(ctx context.Context, contentID uuid.UUID) int {
Expand Down
Loading