nolint:dupl // symmetric with cloneDetachedDirectoryForContainerResult; sharing obscures type specifics
(ctx context.Context, src *File)
| 868 | |
| 869 | //nolint:dupl // symmetric with cloneDetachedDirectoryForContainerResult; sharing obscures type specifics |
| 870 | func 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 | |
| 905 | func CloneContainerMetaSnapshot(ctx context.Context, src *LazyAccessor[bkcache.ImmutableRef, *Container]) (*LazyAccessor[bkcache.ImmutableRef, *Container], error) { |
| 906 | if src == nil { |
no test coverage detected