jellyfin-server/MediaBrowser.Server.Startup.Common/Migrations/MigrateUserFolders.cs

42 lines
1.1 KiB
C#
Raw Normal View History

using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
2014-11-11 03:41:55 +00:00
using System;
using System.IO;
using System.Linq;
2015-10-04 04:23:11 +00:00
using CommonIO;
2014-11-11 03:41:55 +00:00
namespace MediaBrowser.Server.Startup.Common.Migrations
{
public class MigrateUserFolders : IVersionMigration
{
private readonly IServerApplicationPaths _appPaths;
private readonly IFileSystem _fileSystem;
2014-11-11 03:41:55 +00:00
public MigrateUserFolders(IServerApplicationPaths appPaths, IFileSystem fileSystem)
2014-11-11 03:41:55 +00:00
{
_appPaths = appPaths;
_fileSystem = fileSystem;
2014-11-11 03:41:55 +00:00
}
public void Run()
{
try
{
var rootPath = _appPaths.RootFolderPath;
2015-09-13 21:32:02 +00:00
var folders = _fileSystem.GetDirectories(rootPath)
.Where(i => !string.Equals(i.Name, "default", StringComparison.OrdinalIgnoreCase))
2014-11-11 03:41:55 +00:00
.ToList();
foreach (var folder in folders)
{
_fileSystem.DeleteDirectory(folder.FullName, true);
2014-11-11 03:41:55 +00:00
}
}
catch (IOException)
{
}
}
}
}