diff --git a/EasyWeb/Services/EntryService.cs b/EasyWeb/Services/EntryService.cs index 82fc196..afdf7a3 100644 --- a/EasyWeb/Services/EntryService.cs +++ b/EasyWeb/Services/EntryService.cs @@ -282,6 +282,14 @@ public FileEntry GetLink(FileEntry entry) } private FileEntry MatchLink(Int32 storageId, Int32 parentId, String[] matchs) + { + return MatchLinks(storageId, parentId, matchs) + .OrderByDescending(e => e.Version) + .ThenBy(e => e.Name.Length) + .FirstOrDefault(); + } + + private IList MatchLinks(Int32 storageId, Int32 parentId, String[] matchs) { var m = matchs[0]; var flag = true; @@ -301,7 +309,7 @@ private FileEntry MatchLink(Int32 storageId, Int32 parentId, String[] matchs) else childs = childs.Where(e => !e.IsDirectory && !m.IsMatch(e.Name)).ToList(); - return childs.OrderByDescending(e => e.LastWrite).FirstOrDefault(); + return childs; } else { @@ -312,17 +320,21 @@ private FileEntry MatchLink(Int32 storageId, Int32 parentId, String[] matchs) if (childs.Count == 0) return null; // 递归查找子目录,找到最新的文件 - FileEntry fe = null; + var links = new List(); foreach (var item in childs) { - var rs = MatchLink(storageId, item.Id, matchs[1..]); - if (rs != null && (fe == null || rs.Version > fe.Version)) - { - fe = rs; - } + var rs = MatchLinks(storageId, item.Id, matchs[1..]); + if (rs != null) links.AddRange(rs); } - return fe; + //var fe = links.OrderByDescending(e => e.Version).FirstOrDefault(); + //return fe; + if (links.Count > 0) + { + var max = links.Max(e => e.Version); + links = links.Where(e => e.Version == max).ToList(); + } + return links; } }