MCPcopy Index your code
hub / github.com/dagger/dagger / cloneDetachedFileForContainerResult

Function cloneDetachedFileForContainerResult

core/container.go:870–903  ·  view source on GitHub ↗

nolint:dupl // symmetric with cloneDetachedDirectoryForContainerResult; sharing obscures type specifics

(ctx context.Context, src *File)

Source from the content-addressed store, hash-verified

868
869//nolint:dupl // symmetric with cloneDetachedDirectoryForContainerResult; sharing obscures type specifics
870func cloneDetachedFileForContainerResult(ctx context.Context, src *File) (*File, error) {
871 if src == nil {
872 return nil, nil
873 }
874 if src.Lazy != nil {
875 return nil, fmt.Errorf("clone detached file for container result: file must be materialized, got lazy %T", src.Lazy)
876 }
877
878 cp := &File{
879 Platform: src.Platform,
880 Services: slices.Clone(src.Services),
881 File: new(LazyAccessor[string, *File]),
882 Snapshot: new(LazyAccessor[bkcache.ImmutableRef, *File]),
883 }
884 if filePath, ok := src.File.Peek(); ok {
885 cp.File.setValue(filePath)
886 }
887
888 snapshot, ok := src.Snapshot.Peek()
889 if !ok || snapshot == nil {
890 return cp, nil
891 }
892
893 query, err := CurrentQuery(ctx)
894 if err != nil {
895 return nil, err
896 }
897 reopened, err := query.SnapshotManager().GetBySnapshotID(ctx, snapshot.SnapshotID(), bkcache.NoUpdateLastUsed)
898 if err != nil {
899 return nil, err
900 }
901 cp.Snapshot.setValue(reopened)
902 return cp, nil
903}
904
905func CloneContainerMetaSnapshot(ctx context.Context, src *LazyAccessor[bkcache.ImmutableRef, *Container]) (*LazyAccessor[bkcache.ImmutableRef, *Container], error) {
906 if src == nil {

Callers 3

EvaluateMethod · 0.85
WithMountedFileMethod · 0.85

Calls 7

CurrentQueryFunction · 0.85
PeekMethod · 0.80
CloneMethod · 0.65
GetBySnapshotIDMethod · 0.65
SnapshotManagerMethod · 0.65
SnapshotIDMethod · 0.65
setValueMethod · 0.45

Tested by

no test coverage detected