forked from longtao.wu/droboticflow
32 lines
1010 B
Go
32 lines
1010 B
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"strings"
|
|
|
|
"droboticflow/internal/domain"
|
|
"droboticflow/internal/objectsync"
|
|
)
|
|
|
|
func (s *server) finalizeVerifiedDirect(ctx context.Context, item *domain.ObjectSyncItemRecord, remote domain.ObjectStorageObjectSummary) {
|
|
if item.StagingKey != item.TargetKey || item.Action != "create" {
|
|
return
|
|
}
|
|
publisher, e := objectsync.NewCoordinator(s.store, objectsync.BOSPublisher{}, "api-upload-complete")
|
|
if e != nil {
|
|
return
|
|
}
|
|
metadata := make(map[string]string, len(remote.Metadata))
|
|
for key := range remote.Metadata {
|
|
metadata[strings.ToLower(key)] = objectSyncMetadataValue(remote.Metadata, key)
|
|
}
|
|
result, e := publisher.FinalizeDirectUpload(ctx, item.ID, objectsync.ObjectMetadata{Exists: true, ETag: strings.Trim(remote.ETag, "\""), SizeBytes: remote.SizeBytes, VersionID: remote.VersionID, UserMeta: metadata})
|
|
if result != nil {
|
|
*item = *result
|
|
}
|
|
if e != nil {
|
|
log.Printf("[drosync] verified finalize deferred to recovery item=%s", item.ID)
|
|
}
|
|
}
|