Bug Squashing

This commit is contained in:
Steven Hildreth 2019-01-29 21:16:49 -06:00
parent 56c33c19dc
commit 6a985a7316
13 changed files with 202 additions and 159 deletions

View file

@ -15,8 +15,7 @@ namespace Roadie.Library.Data
public ApplicationUser User { get; set; }
[Column("userId")]
[Required]
public int UserId { get; set; }
public int? UserId { get; set; }
[NotMapped]
public new bool? IsLocked { get; set; }

View file

@ -642,7 +642,8 @@ namespace Roadie.Library.Engines
{
switch (result.ArtistType.ToLower().Replace('-', ' '))
{
case "Artist":
case "artist":
case "artists":
case "one man band":
case "one woman band":
case "solo":

View file

@ -98,6 +98,7 @@ namespace Roadie.Library.Engines
var searchName = metaData.Release.NormalizeName().ToLower();
var specialSearchName = metaData.Release.ToAlphanumericName();
var release = (from r in this.DbContext.Releases
where (r.ArtistId == artist.Id)
where (r.Title.Contains(searchName) ||
r.AlternateNames.Contains(searchName) ||
r.AlternateNames.Contains(specialSearchName))

View file

@ -7,12 +7,9 @@ using Roadie.Library.Extensions;
using Roadie.Library.Factories;
using Roadie.Library.Imaging;
using Roadie.Library.MetaData.Audio;
using Roadie.Library.MetaData.ID3Tags;
using Roadie.Library.MetaData.LastFm;
using Roadie.Library.MetaData.MusicBrainz;
using Roadie.Library.Utility;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -51,9 +48,14 @@ namespace Roadie.Library.FilePlugins
public override async Task<OperationResult<bool>> Process(string destinationRoot, FileInfo fileInfo, bool doJustInfo, int? submissionId)
{
var dr = destinationRoot ?? fileInfo.DirectoryName;
this.Logger.LogTrace(">> Audio: Process destinationRoot [{0}], FileInfo [{1}], doJustInfo [{2}], submissionId [{3}]", destinationRoot, fileInfo, doJustInfo, submissionId);
var sw = Stopwatch.StartNew();
var result = new OperationResult<bool>();
try
{
var dr = destinationRoot ?? fileInfo.DirectoryName;
string destinationName = null;
var metaData = await this.AudioMetaDataHelper.GetInfo(fileInfo, doJustInfo);
@ -97,8 +99,8 @@ namespace Roadie.Library.FilePlugins
this.Logger.LogWarning("Unable To Find ReleaseFolder For MetaData [{0}]", metaData.ToString());
return new OperationResult<bool>("Unable To Find Release Folder");
}
destinationName = FolderPathHelper.TrackFullPath(this.Configuration, metaData, dr, artistFolder);
this.Logger.LogTrace("Info: FileInfo [{0}], Artist Folder [{1}], Destination Name [{2}]", fileInfo.FullName, artistFolder, destinationName);
destinationName = FolderPathHelper.TrackFullPath(this.Configuration, metaData, dr, artistFolder, releaseFolder);
this.Logger.LogTrace("Info: FileInfo [{0}], Artist Folder [{1}], Release Folder [{1}], Destination Name [{3}]", fileInfo.FullName, artistFolder, releaseFolder, destinationName);
if (doJustInfo)
{
@ -178,9 +180,16 @@ namespace Roadie.Library.FilePlugins
{
this.Logger.LogTrace("Moving File To [{0}]", destinationName);
if (!doJustInfo)
{
try
{
fileInfo.MoveTo(destinationName);
}
catch (Exception ex)
{
this.Logger.LogError(ex, "Error Moving File [{0}}", destinationName);
}
}
}
result.AdditionalData.Add(PluginResultInfo.AdditionalDataKeyPluginResultInfo, new PluginResultInfo
@ -194,6 +203,14 @@ namespace Roadie.Library.FilePlugins
TrackTitle = metaData.Title
});
result.IsSuccess = true;
}
catch (Exception ex)
{
this.Logger.LogError(ex, "Error Processing File [{0}}", fileInfo);
}
sw.Stop();
this.Logger.LogTrace("<< Audio: Process Complete. ElapsedTime [{0}]", sw.ElapsedMilliseconds);
return result;
}

View file

@ -9,6 +9,8 @@ using Roadie.Library.Utility;
using System;
using System.Diagnostics;
using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Threading.Tasks;
namespace Roadie.Library.FilePlugins
@ -69,10 +71,10 @@ namespace Roadie.Library.FilePlugins
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
Trace.WriteLine(string.Format("Created Directory [{0}]", folder));
return true;
}
return false;
}
public abstract Task<OperationResult<bool>> Process(string destinationRoot, FileInfo fileInfo, bool doJustInfo, int? submissionId);

View file

@ -8,14 +8,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CsvHelper" Version="12.1.1" />
<PackageReference Include="EFCore.BulkExtensions" Version="2.3.7" />
<PackageReference Include="FluentFTP" Version="19.2.3" />
<PackageReference Include="CsvHelper" Version="12.1.2" />
<PackageReference Include="EFCore.BulkExtensions" Version="2.3.8" />
<PackageReference Include="FluentFTP" Version="19.2.4" />
<PackageReference Include="HtmlAgilityPack" Version="1.8.14" />
<PackageReference Include="IdSharp.Common" Version="1.0.1" />
<PackageReference Include="IdSharp.Tagging" Version="1.0.0-rc3" />
<PackageReference Include="Inflatable.Lastfm" Version="1.1.0.339" />
<PackageReference Include="Mapster" Version="3.2.0" />
<PackageReference Include="Mapster" Version="3.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
@ -26,6 +26,7 @@
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0005" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0005" />
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0007" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.5.0" />
<PackageReference Include="System.Runtime.Caching" Version="4.5.0" />
</ItemGroup>

View file

@ -154,9 +154,13 @@ namespace Roadie.Library.Utility
/// <param name="metaData">Populated Track MetaData</param>
/// <param name="destinationFolder">Optional Root folder defaults to Library Folder from Settings</param>
/// <param name="artistFolder">Optional ArtistFolder default is to get from MetaData artist</param>
public static string TrackFullPath(IRoadieSettings configuration, AudioMetaData metaData, string destinationFolder = null, string artistFolder = null)
public static string TrackFullPath(IRoadieSettings configuration, AudioMetaData metaData, string destinationFolder = null, string artistFolder = null, string releaseFolder = null)
{
return FolderPathHelper.TrackFullPath(configuration, metaData.Artist, metaData.Release, SafeParser.ToDateTime(metaData.Year).Value, metaData.Title, metaData.TrackNumber ?? 0, destinationFolder, metaData.Disk ?? 0, metaData.TotalTrackNumbers ?? 0, artistFolder: artistFolder);
return FolderPathHelper.TrackFullPath(configuration, metaData.Artist, metaData.Release, SafeParser.ToDateTime(metaData.Year).Value,
metaData.Title, metaData.TrackNumber ?? 0, destinationFolder, metaData.Disk ?? 0,
metaData.TotalTrackNumbers ?? 0,
artistFolder: artistFolder,
releaseFolder: releaseFolder);
}
/// <summary>
@ -183,15 +187,15 @@ namespace Roadie.Library.Utility
/// <param name="diskNumber">Optional disk number defaults to 0</param>
/// <param name="totalTrackNumber">Optional Total Tracks defaults to TrackNumber</param>
/// <param name="fileExtension">Optional File Extension defaults to mp3</param>
public static string TrackFullPath(IRoadieSettings configuration, string artistSortName, string releaseTitle, DateTime releaseDate, string trackTitle, short trackNumber, string destinationFolder = null, int? diskNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3", string artistFolder = null)
public static string TrackFullPath(IRoadieSettings configuration, string artistSortName, string releaseTitle, DateTime releaseDate, string trackTitle, short trackNumber, string destinationFolder = null, int? diskNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3", string artistFolder = null, string releaseFolder = null)
{
destinationFolder = destinationFolder ?? configuration.LibraryFolder;
artistFolder = artistFolder ?? FolderPathHelper.ArtistPath(configuration, artistSortName, destinationFolder);
var releaseFolder = FolderPathHelper.ReleasePath(artistFolder, releaseTitle, releaseDate);
releaseFolder = releaseFolder ?? FolderPathHelper.ReleasePath(artistFolder, releaseTitle, releaseDate);
var trackFileName = FolderPathHelper.TrackFileName(configuration, trackTitle, trackNumber, diskNumber, totalTrackNumber, fileExtension);
var result = Path.Combine(artistFolder, releaseFolder, trackFileName);
Trace.WriteLine(string.Format("TrackPath [{0}] For ArtistName [{1}], ReleaseTitle [{2}], ReleaseDate [{3}], TrackNumber [{4}]", result, artistSortName, releaseTitle, releaseDate, trackNumber));
Trace.WriteLine(string.Format("TrackPath [{0}] For ArtistName [{1}], ReleaseTitle [{2}], ReleaseDate [{3}], ReleaseYear [{4}], TrackNumber [{5}]", result, artistSortName, releaseTitle, releaseDate.ToString("s"), releaseDate.ToString("yyyy"), trackNumber));
return result;
}

View file

@ -142,7 +142,7 @@ namespace Roadie.Api.Services
};
}
public Task<Library.Models.Pagination.PagedResult<ArtistList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, bool? onlyIncludeWithReleases = true)
public async Task<Library.Models.Pagination.PagedResult<ArtistList>> List(User roadieUser, PagedRequest request, bool? doRandomize = false, bool? onlyIncludeWithReleases = true)
{
var sw = new Stopwatch();
sw.Start();
@ -258,14 +258,25 @@ namespace Roadie.Api.Services
}
}
sw.Stop();
return Task.FromResult(new Library.Models.Pagination.PagedResult<ArtistList>
if(!string.IsNullOrEmpty(request.Filter) && rowCount == 0)
{
// Create request for no artist found
var req = new data.Request
{
UserId = roadieUser?.Id,
Description = request.Filter
};
this.DbContext.Requests.Add(req);
await this.DbContext.SaveChangesAsync();
}
return new Library.Models.Pagination.PagedResult<ArtistList>
{
TotalCount = rowCount,
CurrentPage = request.PageValue,
TotalPages = (int)Math.Ceiling((double)rowCount / request.LimitValue),
OperationTime = sw.ElapsedMilliseconds,
Rows = rows
});
};
}
public async Task<OperationResult<bool>> ScanArtistReleasesFolders(Guid artistId, string destinationFolder, bool doJustInfo)

View file

@ -53,12 +53,19 @@ namespace Roadie.Api.Controllers
}, ControllerCacheRegionUrn);
}
}
if(this._currentUser == null)
{
throw new Exception("Access Denied");
}
return this._currentUser;
}
protected models.User UserModelForUser(ApplicationUser user)
{
if(user == null)
{
return null;
}
var result = user.Adapt<models.User>();
result.IsAdmin = User.IsInRole("Admin");
result.IsEditor = User.IsInRole("Editor") || result.IsAdmin;

View file

@ -14,7 +14,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>68c80416-0d72-409d-b727-3fea7ab7fd2c</ProjectGuid>
<publishUrl>bin\x64\Debug\netcoreapp2.2\publish\</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>netcoreapp2.2</TargetFramework>
<SelfContained>false</SelfContained>
<_IsPortable>true</_IsPortable>

View file

@ -3,7 +3,7 @@
"Roadie.Api": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5123/"
}

View file

@ -23,7 +23,7 @@
<ItemGroup>
<PackageReference Include="BCrypt-Core" Version="2.0.0" />
<PackageReference Include="Mapster" Version="3.2.0" />
<PackageReference Include="Mapster" Version="3.3.0" />
<PackageReference Include="Microsoft.AspNet.SignalR" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.All" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.1.0" />

View file

@ -48,24 +48,24 @@ Global
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Debug|x64.Build.0 = Debug|x64
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|Any CPU.Build.0 = Release|Any CPU
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.ActiveCfg = Release|Any CPU
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.Build.0 = Release|Any CPU
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.ActiveCfg = Release|x64
{52E58F4B-88F0-4336-AD06-1184E857FA2C}.Release|x64.Build.0 = Release|x64
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Debug|x64.ActiveCfg = Debug|x64
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Debug|x64.Build.0 = Debug|x64
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|Any CPU.Build.0 = Release|Any CPU
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|x64.ActiveCfg = Release|Any CPU
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|x64.Build.0 = Release|Any CPU
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|x64.ActiveCfg = Release|x64
{7B37031E-F2AE-4BE2-9F6F-005CA7A6FDF1}.Release|x64.Build.0 = Release|x64
{E740C89E-3363-4577-873B-0871823E252C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E740C89E-3363-4577-873B-0871823E252C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E740C89E-3363-4577-873B-0871823E252C}.Debug|x64.ActiveCfg = Debug|x64
{E740C89E-3363-4577-873B-0871823E252C}.Debug|x64.Build.0 = Debug|x64
{E740C89E-3363-4577-873B-0871823E252C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E740C89E-3363-4577-873B-0871823E252C}.Release|Any CPU.Build.0 = Release|Any CPU
{E740C89E-3363-4577-873B-0871823E252C}.Release|x64.ActiveCfg = Release|Any CPU
{E740C89E-3363-4577-873B-0871823E252C}.Release|x64.Build.0 = Release|Any CPU
{E740C89E-3363-4577-873B-0871823E252C}.Release|x64.ActiveCfg = Release|x64
{E740C89E-3363-4577-873B-0871823E252C}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE