mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 18:42:52 -07:00
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using MediaBrowser.Common.IO;
|
|
using MediaBrowser.Controller;
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using CommonIO;
|
|
|
|
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 = _fileSystem.GetDirectories(rootPath)
|
|
.Where(i => !string.Equals(i.Name, "default", StringComparison.OrdinalIgnoreCase))
|
|
.ToList();
|
|
|
|
foreach (var folder in folders)
|
|
{
|
|
_fileSystem.DeleteDirectory(folder.FullName, true);
|
|
}
|
|
}
|
|
catch (IOException)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|