add endpoint to get file list

pull/702/head
Luke Pulverenti 8 years ago
parent 72f9a4e478
commit c929fb187e

@ -58,6 +58,11 @@ namespace MediaBrowser.WebDashboard.Api
{ {
} }
[Route("/web/cachefiles", "GET")]
public class GetCacheFiles
{
}
/// <summary> /// <summary>
/// Class GetDashboardResource /// Class GetDashboardResource
/// </summary> /// </summary>
@ -140,6 +145,22 @@ namespace MediaBrowser.WebDashboard.Api
return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml("dummy.html", page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false)); return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml("dummy.html", page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false));
} }
public object Get(GetCacheFiles request)
{
var creator = GetPackageCreator();
var directory = creator.DashboardUIPath;
var skipExtensions = GetUndeployedExtensions();
var allFiles =
Directory.GetFiles(directory, "*", SearchOption.AllDirectories)
.Where(i => !skipExtensions.Contains(Path.GetExtension(i) ?? string.Empty, StringComparer.OrdinalIgnoreCase))
.Select(i => i.Replace(directory, string.Empty, StringComparison.OrdinalIgnoreCase).Replace("\\", "/").TrimStart('/') + "?v=" + _appHost.ApplicationVersion.ToString())
.ToList();
return ResultFactory.GetOptimizedResult(Request, _jsonSerializer.SerializeToString(allFiles));
}
/// <summary> /// <summary>
/// Gets the specified request. /// Gets the specified request.
/// </summary> /// </summary>
@ -274,6 +295,21 @@ namespace MediaBrowser.WebDashboard.Api
return new PackageCreator(_fileSystem, _localization, Logger, _serverConfigurationManager, _jsonSerializer); return new PackageCreator(_fileSystem, _localization, Logger, _serverConfigurationManager, _jsonSerializer);
} }
private List<string> GetUndeployedExtensions()
{
var list = new List<string>();
list.Add(".log");
list.Add(".txt");
list.Add(".map");
list.Add(".md");
list.Add(".gz");
list.Add(".bat");
list.Add(".sh");
return list;
}
public async Task<object> Get(GetDashboardPackage request) public async Task<object> Get(GetDashboardPackage request)
{ {
var path = Path.Combine(_serverConfigurationManager.ApplicationPaths.ProgramDataPath, var path = Path.Combine(_serverConfigurationManager.ApplicationPaths.ProgramDataPath,
@ -313,14 +349,9 @@ namespace MediaBrowser.WebDashboard.Api
//bowerPath = versionedBowerPath; //bowerPath = versionedBowerPath;
} }
DeleteFilesByExtension(bowerPath, ".log"); GetUndeployedExtensions().ForEach(i => DeleteFilesByExtension(bowerPath, i));
DeleteFilesByExtension(bowerPath, ".txt");
DeleteFilesByExtension(bowerPath, ".map");
DeleteFilesByExtension(bowerPath, ".md");
DeleteFilesByExtension(bowerPath, ".json", "strings\\"); DeleteFilesByExtension(bowerPath, ".json", "strings\\");
DeleteFilesByExtension(bowerPath, ".gz");
DeleteFilesByExtension(bowerPath, ".bat");
DeleteFilesByExtension(bowerPath, ".sh");
DeleteFilesByName(bowerPath, "copying", true); DeleteFilesByName(bowerPath, "copying", true);
DeleteFilesByName(bowerPath, "license", true); DeleteFilesByName(bowerPath, "license", true);
DeleteFilesByName(bowerPath, "license-mit", true); DeleteFilesByName(bowerPath, "license-mit", true);
@ -364,8 +395,6 @@ namespace MediaBrowser.WebDashboard.Api
{ {
// Delete things that are unneeded in an attempt to keep the output as trim as possible // Delete things that are unneeded in an attempt to keep the output as trim as possible
_fileSystem.DeleteDirectory(Path.Combine(path, "css", "images", "tour"), true); _fileSystem.DeleteDirectory(Path.Combine(path, "css", "images", "tour"), true);
_fileSystem.DeleteFile(Path.Combine(path, "thirdparty", "jquerymobile-1.4.5", "jquery.mobile-1.4.5.min.map"));
} }
else else
{ {

Loading…
Cancel
Save