diff options
Diffstat (limited to 'MediaBrowser.WebDashboard/Api/DashboardService.cs')
| -rw-r--r-- | MediaBrowser.WebDashboard/Api/DashboardService.cs | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 69c4417cb..030dc7f33 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -17,6 +17,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using CommonIO; using WebMarkupMin.Core.Minifiers; namespace MediaBrowser.WebDashboard.Api @@ -274,8 +275,8 @@ namespace MediaBrowser.WebDashboard.Api private void CopyFile(string src, string dst) { - Directory.CreateDirectory(Path.GetDirectoryName(dst)); - File.Copy(src, dst, true); + _fileSystem.CreateDirectory(Path.GetDirectoryName(dst)); + _fileSystem.CopyFile(src, dst, true); } public async Task<object> Get(GetDashboardPackage request) @@ -306,17 +307,17 @@ namespace MediaBrowser.WebDashboard.Api { // Overwrite certain files with cordova specific versions var cordovaVersion = Path.Combine(path, "cordova", "registrationservices.js"); - File.Copy(cordovaVersion, Path.Combine(path, "scripts", "registrationservices.js"), true); - File.Delete(cordovaVersion); + _fileSystem.CopyFile(cordovaVersion, Path.Combine(path, "scripts", "registrationservices.js"), true); + _fileSystem.DeleteFile(cordovaVersion); // Delete things that are unneeded in an attempt to keep the output as trim as possible - Directory.Delete(Path.Combine(path, "css", "images", "tour"), true); - Directory.Delete(Path.Combine(path, "apiclient", "alt"), true); + _fileSystem.DeleteDirectory(Path.Combine(path, "css", "images", "tour"), true); + _fileSystem.DeleteDirectory(Path.Combine(path, "apiclient", "alt"), true); - File.Delete(Path.Combine(path, "thirdparty", "jquerymobile-1.4.5", "jquery.mobile-1.4.5.min.map")); + _fileSystem.DeleteFile(Path.Combine(path, "thirdparty", "jquerymobile-1.4.5", "jquery.mobile-1.4.5.min.map")); - Directory.Delete(Path.Combine(path, "bower_components"), true); - Directory.Delete(Path.Combine(path, "thirdparty", "viblast"), true); + _fileSystem.DeleteDirectory(Path.Combine(path, "bower_components"), true); + _fileSystem.DeleteDirectory(Path.Combine(path, "thirdparty", "viblast"), true); // But we do need this CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "webcomponentsjs", "webcomponents-lite.js"), Path.Combine(path, "bower_components", "webcomponentsjs", "webcomponents-lite.js")); @@ -333,6 +334,8 @@ namespace MediaBrowser.WebDashboard.Api CopyDirectory(Path.Combine(creator.DashboardUIPath, "bower_components", "swipebox", "src", "img"), Path.Combine(path, "bower_components", "swipebox", "src", "img")); CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "hammerjs", "hammer.min.js"), Path.Combine(path, "bower_components", "hammerjs", "hammer.min.js")); + + CopyFile(Path.Combine(creator.DashboardUIPath, "bower_components", "Sortable", "Sortable.min.js"), Path.Combine(path, "bower_components", "Sortable", "Sortable.min.js")); } MinifyCssDirectory(Path.Combine(path, "css")); @@ -355,7 +358,7 @@ namespace MediaBrowser.WebDashboard.Api { try { - var text = File.ReadAllText(file, Encoding.UTF8); + var text = _fileSystem.ReadAllText(file, Encoding.UTF8); var result = new KristensenCssMinifier().Minify(text, false, Encoding.UTF8); @@ -366,7 +369,7 @@ namespace MediaBrowser.WebDashboard.Api else { text = result.MinifiedContent; - File.WriteAllText(file, text, Encoding.UTF8); + _fileSystem.WriteAllText(file, text, Encoding.UTF8); } } catch (Exception ex) @@ -382,7 +385,7 @@ namespace MediaBrowser.WebDashboard.Api { try { - var text = File.ReadAllText(file, Encoding.UTF8); + var text = _fileSystem.ReadAllText(file, Encoding.UTF8); var result = new CrockfordJsMinifier().Minify(text, false, Encoding.UTF8); @@ -393,7 +396,7 @@ namespace MediaBrowser.WebDashboard.Api else { text = result.MinifiedContent; - File.WriteAllText(file, text, Encoding.UTF8); + _fileSystem.WriteAllText(file, text, Encoding.UTF8); } } catch (Exception ex) @@ -416,13 +419,12 @@ namespace MediaBrowser.WebDashboard.Api if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)) { - excludeFiles.Add("supporter.html"); excludeFiles.Add("supporterkey.html"); } foreach (var file in excludeFiles) { - File.Delete(Path.Combine(destination, file)); + _fileSystem.DeleteFile(Path.Combine(destination, file)); } } @@ -449,17 +451,17 @@ namespace MediaBrowser.WebDashboard.Api private void CopyDirectory(string source, string destination) { - Directory.CreateDirectory(destination); + _fileSystem.CreateDirectory(destination); //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(source, "*", SearchOption.AllDirectories)) - Directory.CreateDirectory(dirPath.Replace(source, destination)); + _fileSystem.CreateDirectory(dirPath.Replace(source, destination)); //Copy all the files & Replaces any files with the same name foreach (string newPath in Directory.GetFiles(source, "*.*", SearchOption.AllDirectories)) - File.Copy(newPath, newPath.Replace(source, destination), true); + _fileSystem.CopyFile(newPath, newPath.Replace(source, destination), true); } } |
