Skip to content

Commit 8344f6a

Browse files
authored
chore: Remove WithResourceMapping(string, string, UnixFileModes) obsolete flag (#964)
1 parent 298aad4 commit 8344f6a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Testcontainers/Builders/ContainerBuilder`3.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,18 @@ public TBuilderEntity WithResourceMapping(byte[] resourceContent, string filePat
195195
}
196196

197197
/// <inheritdoc />
198-
[Obsolete("The next release will change how this member behaves. The target argument, which used to be a file path, will be a directory path where the file will be copied to, similar to WithResourceMapping(DirectoryInfo, string) and WithResourceMapping(FileInfo, string).\nTo retain the old behavior, use WithResourceMapping(FileInfo, FileInfo) instead.")]
199198
public TBuilderEntity WithResourceMapping(string source, string target, UnixFileModes fileMode = Unix.FileMode644)
200199
{
201-
return WithResourceMapping(new FileInfo(source), new FileInfo(target), fileMode);
200+
var fileAttributes = File.GetAttributes(source);
201+
202+
if ((fileAttributes & FileAttributes.Directory) == FileAttributes.Directory)
203+
{
204+
return WithResourceMapping(new DirectoryInfo(source), target, fileMode);
205+
}
206+
else
207+
{
208+
return WithResourceMapping(new FileInfo(source), target, fileMode);
209+
}
202210
}
203211

204212
/// <inheritdoc />

0 commit comments

Comments
 (0)