MigrateUserFolders.cs 979 B

123456789101112131415161718192021222324252627282930313233343536
  1. using MediaBrowser.Controller;
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. namespace MediaBrowser.Server.Startup.Common.Migrations
  6. {
  7. public class MigrateUserFolders : IVersionMigration
  8. {
  9. private readonly IServerApplicationPaths _appPaths;
  10. public MigrateUserFolders(IServerApplicationPaths appPaths)
  11. {
  12. _appPaths = appPaths;
  13. }
  14. public void Run()
  15. {
  16. try
  17. {
  18. var rootPath = _appPaths.RootFolderPath;
  19. var folders = new DirectoryInfo(rootPath).EnumerateDirectories("*", SearchOption.TopDirectoryOnly).Where(i => !string.Equals(i.Name, "default", StringComparison.OrdinalIgnoreCase))
  20. .ToList();
  21. foreach (var folder in folders)
  22. {
  23. Directory.Delete(folder.FullName, true);
  24. }
  25. }
  26. catch (IOException)
  27. {
  28. }
  29. }
  30. }
  31. }