You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Server.Startup.../Migrations/MigrateUserFolders.cs

40 lines
1.1 KiB

using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
using System;
using System.IO;
using System.Linq;
namespace MediaBrowser.Server.Startup.Common.Migrations
{
public class MigrateUserFolders : IVersionMigration
{
private readonly IServerApplicationPaths _appPaths;
private readonly IFileSystem _fileSystem;
public MigrateUserFolders(IServerApplicationPaths appPaths, IFileSystem fileSystem)
{
_appPaths = appPaths;
_fileSystem = fileSystem;
}
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)
{
_fileSystem.DeleteDirectory(folder.FullName, true);
}
}
catch (IOException)
{
}
}
}
}