aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common/Migrations/DeleteDlnaProfiles.cs
blob: 166c2627f134fb59d232acfd023a0be48c6b469c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
using System.IO;

namespace MediaBrowser.Server.Startup.Common.Migrations
{
    public class DeleteDlnaProfiles : IVersionMigration
    {
        private readonly IServerApplicationPaths _appPaths;
        private readonly IFileSystem _fileSystem;

        public DeleteDlnaProfiles(IServerApplicationPaths appPaths, IFileSystem fileSystem)
        {
            _appPaths = appPaths;
            _fileSystem = fileSystem;
        }

        public void Run()
        {
            RemoveProfile("Android");
            RemoveProfile("Windows Phone");
            RemoveProfile("Windows 8 RT");
        }

        private void RemoveProfile(string filename)
        {
            try
            {
                _fileSystem.DeleteFile(Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "system", filename + ".xml"));
            }
            catch
            {

            }
            try
            {
                _fileSystem.DeleteFile(Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "user", filename + ".xml"));
            }
            catch
            {

            }
        }
    }
}