Skip to content

Commit

Permalink
Fixed issue with non-lowercase extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Oct 17, 2017
1 parent 289e0f3 commit 57f5012
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/WebDAV-AudioPlayer/Audio/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public async void Play(int index, CancellationToken cancellationToken)

_resourceItemQueue.Enqueue(resourceItem);

string extension = new FileInfo(resourceItem.DisplayName).Extension;
string extension = new FileInfo(resourceItem.DisplayName).Extension.ToLowerInvariant();
switch (extension)
{
case ".wav":
Expand Down
7 changes: 4 additions & 3 deletions src/WebDAV-AudioPlayer/Client/DecaTecWebDavClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ namespace WebDav.AudioPlayer.Client
{
public class DecaTecWebDavClient : IWebDavClient
{
private static Func<WebDavSessionListItem, bool> _isAudioFile = r => r.Name.EndsWith(".wav") || r.Name.EndsWith(".wma") || r.Name.EndsWith(".mp3") || r.Name.EndsWith(".mp4") || r.Name.EndsWith(".m4a") || r.Name.EndsWith(".aac") || r.Name.EndsWith(".ogg") || r.Name.EndsWith(".flac");
private static Func<WebDavSessionListItem, bool> _isFolder = r => r.IsCollection;
private static readonly string[] AudioExtensions = { ".wav", ".wma", ".mp3", ".mp4", ".m4a", ".aac", ".ogg", ".flac" };
private static readonly Func<WebDavSessionListItem, bool> IsAudioFile = r => AudioExtensions.Any(e => r.Name.ToLowerInvariant().EndsWith(e));
private static readonly Func<WebDavSessionListItem, bool> IsFolder = r => r.IsCollection;

private readonly WebDavSession _session;
private readonly IConnectionSettings _connectionSettings;
Expand Down Expand Up @@ -65,7 +66,7 @@ public async Task<ResourceLoadStatus> FetchChildResourcesAsync(ResourceItem pare
if (result != null)
{
var tasks = result
.Where(r => _isAudioFile(r) || _isFolder(r))
.Where(r => IsAudioFile(r) || IsFolder(r))
.Select(async r =>
{
//Debug.WriteLine("WebDavSessionListItem = " + JsonConvert.SerializeObject(r, Formatting.Indented));
Expand Down
9 changes: 5 additions & 4 deletions src/WebDAV-AudioPlayer/Client/MyWebDavClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ namespace WebDav.AudioPlayer.Client
{
public class MyWebDavClient : IWebDavClient
{
private static Func<WebDavResource, bool> _isAudioFile = r => r.Uri.EndsWith(".wav") || r.Uri.EndsWith(".wma") || r.Uri.EndsWith(".mp3") || r.Uri.EndsWith(".mp4") || r.Uri.EndsWith(".m4a") || r.Uri.EndsWith(".aac") || r.Uri.EndsWith(".ogg") || r.Uri.EndsWith(".flac");
private static Func<WebDavResource, bool> _isFolder = r => r.IsCollection;
private static readonly string[] AudioExtensions = { ".wav", ".wma", ".mp3", ".mp4", ".m4a", ".aac", ".ogg", ".flac" };
private static readonly Func<WebDavResource, bool> IsAudioFile = r => AudioExtensions.Any(e => r.Uri.ToLowerInvariant().EndsWith(e));
private static readonly Func<WebDavResource, bool> IsFolder = r => r.IsCollection;

private readonly WebDavClient _client;
private readonly IConnectionSettings _connectionSettings;
Expand Down Expand Up @@ -46,7 +47,7 @@ public async Task<ResourceLoadStatus> FetchChildResourcesAsync([NotNull] Resourc
if (result.Resources != null)
{
var tasks = result.Resources.Skip(1)
.Where(r => _isAudioFile(r) || _isFolder(r))
.Where(r => IsAudioFile(r) || IsFolder(r))
.Select(async r =>
{
Uri fullPath = OnlinePathBuilder.Combine(_connectionSettings.StorageUri, r.Uri);
Expand Down Expand Up @@ -150,7 +151,7 @@ public async Task<ResourceLoadStatus> DownloadFolderAsync(ResourceItem folder, s
notify(isSuccessful, resourceItem, idx, folder.Items.Count);
idx++;
}
finally
finally
{
resourceItem.Stream.Dispose();
resourceItem.Stream = null;
Expand Down

0 comments on commit 57f5012

Please sign in to comment.