【修复】修复unity项目中彻底移除某个模块后,重新生成代码过程中会尝试删除该模块目录,由于保留了meta文件导致目录删除失败的bug

main
walon 2021-12-02 18:11:39 +08:00
parent 91bb1b317f
commit 6bcc8e74ce
5 changed files with 26 additions and 6 deletions

View File

@ -90,7 +90,7 @@ namespace Luban.Client.Common.Utils
else else
{ {
s_logger.Info("[remove] dir: {dir}", subDir); s_logger.Info("[remove] dir: {dir}", subDir);
Directory.Delete(subDir); FileUtil.DeleteDirectoryRecursive(subDir);
} }
} }
} }

View File

@ -219,5 +219,24 @@ namespace Luban.Common.Utils
} }
return bytes; return bytes;
} }
public static void DeleteDirectoryRecursive(string rootDir)
{
string[] files = Directory.GetFiles(rootDir);
string[] dirs = Directory.GetDirectories(rootDir);
foreach (string file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
foreach (string dir in dirs)
{
DeleteDirectoryRecursive(dir);
}
Directory.Delete(rootDir, false);
}
} }
} }

View File

@ -27,7 +27,7 @@ namespace Luban.Job.Cfg.Validators
public RefValidator(TType type, string tablesStr) public RefValidator(TType type, string tablesStr)
{ {
Type = type; Type = type;
this.Tables = new List<string>(DefUtil.TrimBracePairs(tablesStr).Split(',')); this.Tables = DefUtil.TrimBracePairs(tablesStr).Split(',').Select(s => s.Trim()).ToList();
} }
public void Validate(ValidatorContext ctx, TType type, DType key) public void Validate(ValidatorContext ctx, TType type, DType key)

View File

@ -164,7 +164,7 @@ namespace Luban.Job.Common.Defs
private void AddModule(string defineFile, XElement me) private void AddModule(string defineFile, XElement me)
{ {
var name = XmlUtil.GetOptionalAttribute(me, "name"); var name = XmlUtil.GetOptionalAttribute(me, "name")?.Trim();
//if (string.IsNullOrEmpty(name)) //if (string.IsNullOrEmpty(name))
//{ //{
// throw new LoadDefException($"xml:{CurImportFile} contains module which's name is empty"); // throw new LoadDefException($"xml:{CurImportFile} contains module which's name is empty");
@ -235,7 +235,7 @@ namespace Luban.Job.Common.Defs
} }
var b = new Bean() var b = new Bean()
{ {
Name = XmlUtil.GetRequiredAttribute(e, "name"), Name = XmlUtil.GetRequiredAttribute(e, "name").Trim(),
Namespace = CurNamespace, Namespace = CurNamespace,
Parent = parent.Length > 0 ? parent : "", Parent = parent.Length > 0 ? parent : "",
TypeId = XmlUtil.GetOptionIntAttribute(e, "id"), TypeId = XmlUtil.GetOptionIntAttribute(e, "id"),
@ -319,7 +319,7 @@ namespace Luban.Job.Common.Defs
ValidAttrKeys(defineFile, e, _enumOptionalAttrs, _enumRequiredAttrs); ValidAttrKeys(defineFile, e, _enumOptionalAttrs, _enumRequiredAttrs);
var en = new PEnum() var en = new PEnum()
{ {
Name = XmlUtil.GetRequiredAttribute(e, "name"), Name = XmlUtil.GetRequiredAttribute(e, "name").Trim(),
Namespace = CurNamespace, Namespace = CurNamespace,
Comment = XmlUtil.GetOptionalAttribute(e, "comment"), Comment = XmlUtil.GetOptionalAttribute(e, "comment"),
IsFlags = XmlUtil.GetOptionBoolAttribute(e, "flags"), IsFlags = XmlUtil.GetOptionBoolAttribute(e, "flags"),

View File

@ -81,7 +81,8 @@ namespace Luban.Job.Common.Defs
{ {
return null; return null;
} }
return ExternalType.Mappers.Find(m => m.Lan == DefAssemblyBase.LocalAssebmly.CurrentLanguage);
return ExternalType.Mappers.Find(m => m.Lan == this.AssemblyBase.CurrentLanguage && this.AssemblyBase.CurrentExternalSelectors.Contains(m.Selector));
} }
} }