Ignore Mac metadata hidden files ._* (#443)
* Implemented the ability to completely ignore all MacOS ._ files. They are ignored for all I/O operations (on all OSes)
This commit is contained in:
parent
a349f16ed4
commit
434bcdae4c
4 changed files with 20 additions and 7 deletions
|
@ -25,6 +25,7 @@ namespace API.Services
|
|||
/// <summary>
|
||||
/// Given a set of regex search criteria, get files in the given path.
|
||||
/// </summary>
|
||||
/// <remarks>This will always exclude <see cref="Parser.Parser.MacOsMetadataFileStartsWith"/> patterns</remarks>
|
||||
/// <param name="path">Directory to search</param>
|
||||
/// <param name="searchPatternExpression">Regex version of search pattern (ie \.mp3|\.mp4). Defaults to * meaning all files.</param>
|
||||
/// <param name="searchOption">SearchOption to use, defaults to TopDirectoryOnly</param>
|
||||
|
@ -35,9 +36,10 @@ namespace API.Services
|
|||
{
|
||||
if (!Directory.Exists(path)) return ImmutableList<string>.Empty;
|
||||
var reSearchPattern = new Regex(searchPatternExpression, RegexOptions.IgnoreCase);
|
||||
|
||||
return Directory.EnumerateFiles(path, "*", searchOption)
|
||||
.Where(file =>
|
||||
reSearchPattern.IsMatch(Path.GetExtension(file)));
|
||||
reSearchPattern.IsMatch(Path.GetExtension(file)) && !Path.GetFileName(file).StartsWith(Parser.Parser.MacOsMetadataFileStartsWith));
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +100,7 @@ namespace API.Services
|
|||
var reSearchPattern = new Regex(searchPatternExpression, RegexOptions.IgnoreCase);
|
||||
return Directory.EnumerateFiles(path, "*", searchOption)
|
||||
.Where(file =>
|
||||
reSearchPattern.IsMatch(file));
|
||||
reSearchPattern.IsMatch(file) && !file.StartsWith(Parser.Parser.MacOsMetadataFileStartsWith));
|
||||
}
|
||||
|
||||
return !Directory.Exists(path) ? Array.Empty<string>() : Directory.GetFiles(path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue