Skip to content

Commit

Permalink
[fix] 修复 DefaultTableImporter错误扫描 ~._开头的被忽略文件的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pirunxi committed Aug 19, 2024
1 parent 44d855c commit fe84ec8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Luban.Core/Utils/FileUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,19 @@ public static void DeleteDirectoryRecursive(string rootDir)
Directory.Delete(rootDir, false);
}

public static bool IsIgnoreFile(string file)
{
return file.Split('\\', '/').Any(fileName => fileName.StartsWith(".") || fileName.StartsWith("_") || fileName.StartsWith("~"));
}

public static List<string> GetFileOrDirectory(string fileOrDirectory)
{
var files = new List<string>();
if (Directory.Exists(fileOrDirectory))
{
foreach (var file in Directory.GetFiles(fileOrDirectory, "*", SearchOption.AllDirectories))
{
if (file.Substring(fileOrDirectory.Length).Split('\\', '/').Any(fileName => fileName.StartsWith(".") || fileName.StartsWith("_") || fileName.StartsWith("~")))
if (IsIgnoreFile(file))
{
continue;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Luban.Schema.Builtin/DefaultTableImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public List<RawTable> LoadImportTables()
var tables = new List<RawTable>();
foreach (string file in Directory.GetFiles(dataDir, "*", SearchOption.AllDirectories))
{
if (FileUtil.IsIgnoreFile(file))
{
continue;
}
string fileName = Path.GetFileName(file);
string ext = Path.GetExtension(fileName).TrimStart('.');
if (!excelExts.Contains(ext))
Expand Down

0 comments on commit fe84ec8

Please sign in to comment.