Skip to content

Add log when Unity failed to create folder #549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion source/AndroidResolver/src/PlayServicesResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ internal static string CopyAssetAndLabel(string sourceLocation, string targetLoc
}

var targetDir = Path.GetDirectoryName(targetLocation);
if (!FileUtils.CreateFolder(targetDir)) {
if (!FileUtils.CreateFolder(targetDir, logger)) {
return String.Format("Failed to create folders at {0}", targetDir);
}

Expand Down
16 changes: 15 additions & 1 deletion source/VersionHandlerImpl/src/FileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ internal static bool IsValidGuid(string guidStr) {
/// </summary>
/// <param name="path">Path to the file/directory that needs checking.</param>
/// <returns>True if all folders are created successfully.</returns>
public static bool CreateFolder(string path) {
public static bool CreateFolder(string path, Google.Logger logger = null) {
if (AssetDatabase.IsValidFolder(path)) {
return true;
}
Expand All @@ -656,6 +656,20 @@ public static bool CreateFolder(string path) {
return true;
}

if (logger != null) {
logger.Log(
String.Format(
"Please ignore Unity error messages similar to '{0}'.\n" +
"Unable to use Unity API `AssetDatabase.CreateFolder()` to " +
"create folder: '{1}'. Switch to use `Directory.CreateDirectory()` " +
"instead. \n\n" +
"See {2} for more information.",
"*** is not a valid directory name.",
path,
"https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-7046"),
LogLevel.Info);
}

return Directory.CreateDirectory(path) != null;
}

Expand Down