2015-01-13 03:46:44 +00:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller;
|
2014-11-11 03:41:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Startup.Common.Migrations
|
|
|
|
|
{
|
|
|
|
|
public class MigrateUserFolders : IVersionMigration
|
|
|
|
|
{
|
|
|
|
|
private readonly IServerApplicationPaths _appPaths;
|
2015-01-13 03:46:44 +00:00
|
|
|
|
private readonly IFileSystem _fileSystem;
|
2014-11-11 03:41:55 +00:00
|
|
|
|
|
2015-01-13 03:46:44 +00:00
|
|
|
|
public MigrateUserFolders(IServerApplicationPaths appPaths, IFileSystem fileSystem)
|
2014-11-11 03:41:55 +00:00
|
|
|
|
{
|
|
|
|
|
_appPaths = appPaths;
|
2015-01-13 03:46:44 +00:00
|
|
|
|
_fileSystem = fileSystem;
|
2014-11-11 03:41:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Run()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var rootPath = _appPaths.RootFolderPath;
|
|
|
|
|
|
|
|
|
|
var folders = new DirectoryInfo(rootPath).EnumerateDirectories("*", SearchOption.TopDirectoryOnly).Where(i => !string.Equals(i.Name, "default", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var folder in folders)
|
|
|
|
|
{
|
2015-01-13 03:46:44 +00:00
|
|
|
|
_fileSystem.DeleteDirectory(folder.FullName, true);
|
2014-11-11 03:41:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (IOException)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|