From 4c69edebe048433977304241e3dbfb9e8a2ab968 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 22 Apr 2013 11:46:23 -0400 Subject: [PATCH] fixes #180 - Deleting users doesn't remove all associated data. --- MediaBrowser.Controller/Entities/User.cs | 2 +- .../Library/UserManager.cs | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index edca21ae7a..e186119d6a 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -312,7 +312,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the path to the user's configuration file /// /// The configuration file path. - private string ConfigurationFilePath + public string ConfigurationFilePath { get { diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 816a726160..e6ffe075d7 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Events; +using System.IO; +using MediaBrowser.Common.Events; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; @@ -485,6 +486,31 @@ namespace MediaBrowser.Server.Implementations.Library await UserRepository.DeleteUser(user, CancellationToken.None).ConfigureAwait(false); + if (user.Configuration.UseCustomLibrary) + { + var path = user.RootFolderPath; + + try + { + Directory.Delete(path, true); + } + catch (IOException ex) + { + _logger.ErrorException("Error deleting directory {0}", ex, path); + } + + path = user.ConfigurationFilePath; + + try + { + File.Delete(path); + } + catch (IOException ex) + { + _logger.ErrorException("Error deleting file {0}", ex, path); + } + } + OnUserDeleted(user); // Force this to be lazy loaded again