mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-17 21:26:13 -04:00
Compare commits
3 Commits
api-docs
...
log-files-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ac61fc4c6 | ||
|
|
46c9b98fad | ||
|
|
7ade5b1259 |
@@ -1,5 +1,5 @@
|
|||||||
import React, { useCallback, useEffect } from 'react';
|
import React, { useCallback, useEffect } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import Button from 'Components/Link/Button';
|
import Button from 'Components/Link/Button';
|
||||||
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
||||||
import InlineMarkdown from 'Components/Markdown/InlineMarkdown';
|
import InlineMarkdown from 'Components/Markdown/InlineMarkdown';
|
||||||
@@ -9,7 +9,6 @@ import ModalFooter from 'Components/Modal/ModalFooter';
|
|||||||
import ModalHeader from 'Components/Modal/ModalHeader';
|
import ModalHeader from 'Components/Modal/ModalHeader';
|
||||||
import usePrevious from 'Helpers/Hooks/usePrevious';
|
import usePrevious from 'Helpers/Hooks/usePrevious';
|
||||||
import { kinds } from 'Helpers/Props';
|
import { kinds } from 'Helpers/Props';
|
||||||
import { fetchUpdates } from 'Store/Actions/systemActions';
|
|
||||||
import UpdateChanges from 'System/Updates/UpdateChanges';
|
import UpdateChanges from 'System/Updates/UpdateChanges';
|
||||||
import useUpdates from 'System/Updates/useUpdates';
|
import useUpdates from 'System/Updates/useUpdates';
|
||||||
import Update from 'typings/Update';
|
import Update from 'typings/Update';
|
||||||
@@ -64,9 +63,8 @@ interface AppUpdatedModalContentProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function AppUpdatedModalContent(props: AppUpdatedModalContentProps) {
|
function AppUpdatedModalContent(props: AppUpdatedModalContentProps) {
|
||||||
const dispatch = useDispatch();
|
|
||||||
const { version, prevVersion } = useSelector((state: AppState) => state.app);
|
const { version, prevVersion } = useSelector((state: AppState) => state.app);
|
||||||
const { isFetched, error, data } = useUpdates();
|
const { isFetched, error, data, refetch } = useUpdates();
|
||||||
const previousVersion = usePrevious(version);
|
const previousVersion = usePrevious(version);
|
||||||
|
|
||||||
const { onModalClose } = props;
|
const { onModalClose } = props;
|
||||||
@@ -77,15 +75,11 @@ function AppUpdatedModalContent(props: AppUpdatedModalContentProps) {
|
|||||||
window.location.href = `${window.Sonarr.urlBase}/system/updates`;
|
window.location.href = `${window.Sonarr.urlBase}/system/updates`;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(fetchUpdates());
|
|
||||||
}, [dispatch]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (version !== previousVersion) {
|
if (version !== previousVersion) {
|
||||||
dispatch(fetchUpdates());
|
refetch();
|
||||||
}
|
}
|
||||||
}, [version, previousVersion, dispatch]);
|
}, [version, previousVersion, refetch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalContent onModalClose={onModalClose}>
|
<ModalContent onModalClose={onModalClose}>
|
||||||
|
|||||||
@@ -62,20 +62,6 @@ export const defaultState = {
|
|||||||
isPopulated: false,
|
isPopulated: false,
|
||||||
error: null,
|
error: null,
|
||||||
items: []
|
items: []
|
||||||
},
|
|
||||||
|
|
||||||
logFiles: {
|
|
||||||
isFetching: false,
|
|
||||||
isPopulated: false,
|
|
||||||
error: null,
|
|
||||||
items: []
|
|
||||||
},
|
|
||||||
|
|
||||||
updateLogFiles: {
|
|
||||||
isFetching: false,
|
|
||||||
isPopulated: false,
|
|
||||||
error: null,
|
|
||||||
items: []
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,11 +80,6 @@ export const RESTORE_BACKUP = 'system/backups/restoreBackup';
|
|||||||
export const CLEAR_RESTORE_BACKUP = 'system/backups/clearRestoreBackup';
|
export const CLEAR_RESTORE_BACKUP = 'system/backups/clearRestoreBackup';
|
||||||
export const DELETE_BACKUP = 'system/backups/deleteBackup';
|
export const DELETE_BACKUP = 'system/backups/deleteBackup';
|
||||||
|
|
||||||
export const FETCH_UPDATES = 'system/updates/fetchUpdates';
|
|
||||||
|
|
||||||
export const FETCH_LOG_FILES = 'system/logFiles/fetchLogFiles';
|
|
||||||
export const FETCH_UPDATE_LOG_FILES = 'system/updateLogFiles/fetchUpdateLogFiles';
|
|
||||||
|
|
||||||
export const RESTART = 'system/restart';
|
export const RESTART = 'system/restart';
|
||||||
export const SHUTDOWN = 'system/shutdown';
|
export const SHUTDOWN = 'system/shutdown';
|
||||||
|
|
||||||
@@ -117,11 +98,6 @@ export const restoreBackup = createThunk(RESTORE_BACKUP);
|
|||||||
export const clearRestoreBackup = createAction(CLEAR_RESTORE_BACKUP);
|
export const clearRestoreBackup = createAction(CLEAR_RESTORE_BACKUP);
|
||||||
export const deleteBackup = createThunk(DELETE_BACKUP);
|
export const deleteBackup = createThunk(DELETE_BACKUP);
|
||||||
|
|
||||||
export const fetchUpdates = createThunk(FETCH_UPDATES);
|
|
||||||
|
|
||||||
export const fetchLogFiles = createThunk(FETCH_LOG_FILES);
|
|
||||||
export const fetchUpdateLogFiles = createThunk(FETCH_UPDATE_LOG_FILES);
|
|
||||||
|
|
||||||
export const restart = createThunk(RESTART);
|
export const restart = createThunk(RESTART);
|
||||||
export const shutdown = createThunk(SHUTDOWN);
|
export const shutdown = createThunk(SHUTDOWN);
|
||||||
|
|
||||||
@@ -200,10 +176,6 @@ export const actionHandlers = handleThunks({
|
|||||||
|
|
||||||
[DELETE_BACKUP]: createRemoveItemHandler(backupsSection, '/system/backup'),
|
[DELETE_BACKUP]: createRemoveItemHandler(backupsSection, '/system/backup'),
|
||||||
|
|
||||||
[FETCH_UPDATES]: createFetchHandler('system.updates', '/update'),
|
|
||||||
[FETCH_LOG_FILES]: createFetchHandler('system.logFiles', '/log/file'),
|
|
||||||
[FETCH_UPDATE_LOG_FILES]: createFetchHandler('system.updateLogFiles', '/log/file/update'),
|
|
||||||
|
|
||||||
[RESTART]: function(getState, payload, dispatch) {
|
[RESTART]: function(getState, payload, dispatch) {
|
||||||
const promise = createAjaxRequest({
|
const promise = createAjaxRequest({
|
||||||
url: '/system/restart',
|
url: '/system/restart',
|
||||||
|
|||||||
@@ -1,46 +1,39 @@
|
|||||||
import React, { useCallback, useEffect } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import AppState from 'App/State/AppState';
|
|
||||||
import * as commandNames from 'Commands/commandNames';
|
import * as commandNames from 'Commands/commandNames';
|
||||||
import { executeCommand } from 'Store/Actions/commandActions';
|
import { executeCommand } from 'Store/Actions/commandActions';
|
||||||
import { fetchLogFiles } from 'Store/Actions/systemActions';
|
|
||||||
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
||||||
import LogFiles from '../LogFiles';
|
import LogFiles from '../LogFiles';
|
||||||
|
import useLogFiles from '../useLogFiles';
|
||||||
|
|
||||||
function AppLogFiles() {
|
function AppLogFiles() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { isFetching, items } = useSelector(
|
const { data = [], isFetching, refetch } = useLogFiles();
|
||||||
(state: AppState) => state.system.logFiles
|
|
||||||
);
|
|
||||||
|
|
||||||
const isDeleteFilesExecuting = useSelector(
|
const isDeleteFilesExecuting = useSelector(
|
||||||
createCommandExecutingSelector(commandNames.DELETE_LOG_FILES)
|
createCommandExecutingSelector(commandNames.DELETE_LOG_FILES)
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRefreshPress = useCallback(() => {
|
const handleRefreshPress = useCallback(() => {
|
||||||
dispatch(fetchLogFiles());
|
refetch();
|
||||||
}, [dispatch]);
|
}, [refetch]);
|
||||||
|
|
||||||
const handleDeleteFilesPress = useCallback(() => {
|
const handleDeleteFilesPress = useCallback(() => {
|
||||||
dispatch(
|
dispatch(
|
||||||
executeCommand({
|
executeCommand({
|
||||||
name: commandNames.DELETE_LOG_FILES,
|
name: commandNames.DELETE_LOG_FILES,
|
||||||
commandFinished: () => {
|
commandFinished: () => {
|
||||||
dispatch(fetchLogFiles());
|
refetch();
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}, [dispatch]);
|
}, [dispatch, refetch]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(fetchLogFiles());
|
|
||||||
}, [dispatch]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LogFiles
|
<LogFiles
|
||||||
isDeleteFilesExecuting={isDeleteFilesExecuting}
|
isDeleteFilesExecuting={isDeleteFilesExecuting}
|
||||||
isFetching={isFetching}
|
isFetching={isFetching}
|
||||||
items={items}
|
items={data}
|
||||||
type="app"
|
type="app"
|
||||||
onRefreshPress={handleRefreshPress}
|
onRefreshPress={handleRefreshPress}
|
||||||
onDeleteFilesPress={handleDeleteFilesPress}
|
onDeleteFilesPress={handleDeleteFilesPress}
|
||||||
|
|||||||
@@ -1,46 +1,39 @@
|
|||||||
import React, { useCallback, useEffect } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import AppState from 'App/State/AppState';
|
|
||||||
import * as commandNames from 'Commands/commandNames';
|
import * as commandNames from 'Commands/commandNames';
|
||||||
import { executeCommand } from 'Store/Actions/commandActions';
|
import { executeCommand } from 'Store/Actions/commandActions';
|
||||||
import { fetchUpdateLogFiles } from 'Store/Actions/systemActions';
|
|
||||||
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
||||||
import LogFiles from '../LogFiles';
|
import LogFiles from '../LogFiles';
|
||||||
|
import { useUpdateLogFiles } from '../useLogFiles';
|
||||||
|
|
||||||
function UpdateLogFiles() {
|
function UpdateLogFiles() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { isFetching, items } = useSelector(
|
const { data = [], isFetching, refetch } = useUpdateLogFiles();
|
||||||
(state: AppState) => state.system.updateLogFiles
|
|
||||||
);
|
|
||||||
|
|
||||||
const isDeleteFilesExecuting = useSelector(
|
const isDeleteFilesExecuting = useSelector(
|
||||||
createCommandExecutingSelector(commandNames.DELETE_UPDATE_LOG_FILES)
|
createCommandExecutingSelector(commandNames.DELETE_UPDATE_LOG_FILES)
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRefreshPress = useCallback(() => {
|
const handleRefreshPress = useCallback(() => {
|
||||||
dispatch(fetchUpdateLogFiles());
|
refetch();
|
||||||
}, [dispatch]);
|
}, [refetch]);
|
||||||
|
|
||||||
const handleDeleteFilesPress = useCallback(() => {
|
const handleDeleteFilesPress = useCallback(() => {
|
||||||
dispatch(
|
dispatch(
|
||||||
executeCommand({
|
executeCommand({
|
||||||
name: commandNames.DELETE_UPDATE_LOG_FILES,
|
name: commandNames.DELETE_UPDATE_LOG_FILES,
|
||||||
commandFinished: () => {
|
commandFinished: () => {
|
||||||
dispatch(fetchUpdateLogFiles());
|
refetch();
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}, [dispatch]);
|
}, [dispatch, refetch]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(fetchUpdateLogFiles());
|
|
||||||
}, [dispatch]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LogFiles
|
<LogFiles
|
||||||
isDeleteFilesExecuting={isDeleteFilesExecuting}
|
isDeleteFilesExecuting={isDeleteFilesExecuting}
|
||||||
isFetching={isFetching}
|
isFetching={isFetching}
|
||||||
items={items}
|
items={data}
|
||||||
type="update"
|
type="update"
|
||||||
onRefreshPress={handleRefreshPress}
|
onRefreshPress={handleRefreshPress}
|
||||||
onDeleteFilesPress={handleDeleteFilesPress}
|
onDeleteFilesPress={handleDeleteFilesPress}
|
||||||
|
|||||||
14
frontend/src/System/Logs/useLogFiles.ts
Normal file
14
frontend/src/System/Logs/useLogFiles.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import useApiQuery from 'Helpers/Hooks/useApiQuery';
|
||||||
|
import LogFile from 'typings/LogFile';
|
||||||
|
|
||||||
|
export default function useLogFiles() {
|
||||||
|
return useApiQuery<LogFile[]>({
|
||||||
|
path: '/log/file',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUpdateLogFiles() {
|
||||||
|
return useApiQuery<LogFile[]>({
|
||||||
|
path: '/log/file/update',
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -15,7 +15,6 @@ import { icons, kinds } from 'Helpers/Props';
|
|||||||
import useUpdateSettings from 'Settings/General/useUpdateSettings';
|
import useUpdateSettings from 'Settings/General/useUpdateSettings';
|
||||||
import { executeCommand } from 'Store/Actions/commandActions';
|
import { executeCommand } from 'Store/Actions/commandActions';
|
||||||
import { fetchGeneralSettings } from 'Store/Actions/settingsActions';
|
import { fetchGeneralSettings } from 'Store/Actions/settingsActions';
|
||||||
import { fetchUpdates } from 'Store/Actions/systemActions';
|
|
||||||
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
|
||||||
import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector';
|
import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector';
|
||||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||||
@@ -114,7 +113,6 @@ function Updates() {
|
|||||||
}, [setIsMajorUpdateModalOpen]);
|
}, [setIsMajorUpdateModalOpen]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(fetchUpdates());
|
|
||||||
dispatch(fetchGeneralSettings());
|
dispatch(fetchGeneralSettings());
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
|
|||||||
41
src/Sonarr.Api.V5/Logs/LogFileController.cs
Normal file
41
src/Sonarr.Api.V5/Logs/LogFileController.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
|
using Sonarr.Http;
|
||||||
|
|
||||||
|
namespace Sonarr.Api.V5.Logs;
|
||||||
|
|
||||||
|
[V5ApiController("log/file")]
|
||||||
|
public class LogFileController : LogFileControllerBase
|
||||||
|
{
|
||||||
|
private readonly IAppFolderInfo _appFolderInfo;
|
||||||
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
|
||||||
|
public LogFileController(IAppFolderInfo appFolderInfo,
|
||||||
|
IDiskProvider diskProvider,
|
||||||
|
IConfigFileProvider configFileProvider)
|
||||||
|
: base(diskProvider, configFileProvider, "")
|
||||||
|
{
|
||||||
|
_appFolderInfo = appFolderInfo;
|
||||||
|
_diskProvider = diskProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<string> GetLogFiles()
|
||||||
|
{
|
||||||
|
return _diskProvider.GetFiles(_appFolderInfo.GetLogFolder(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetLogFilePath(string filename)
|
||||||
|
{
|
||||||
|
return Path.Combine(_appFolderInfo.GetLogFolder(), filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string DownloadUrlRoot
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "logfile";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
71
src/Sonarr.Api.V5/Logs/LogFileControllerBase.cs
Normal file
71
src/Sonarr.Api.V5/Logs/LogFileControllerBase.cs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
|
|
||||||
|
namespace Sonarr.Api.V5.Logs;
|
||||||
|
|
||||||
|
public abstract class LogFileControllerBase : Controller
|
||||||
|
{
|
||||||
|
protected const string LOGFILE_ROUTE = @"/(?<filename>[-.a-zA-Z0-9]+?\.txt)";
|
||||||
|
protected string _resource;
|
||||||
|
|
||||||
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
private readonly IConfigFileProvider _configFileProvider;
|
||||||
|
|
||||||
|
public LogFileControllerBase(IDiskProvider diskProvider,
|
||||||
|
IConfigFileProvider configFileProvider,
|
||||||
|
string resource)
|
||||||
|
{
|
||||||
|
_diskProvider = diskProvider;
|
||||||
|
_configFileProvider = configFileProvider;
|
||||||
|
_resource = resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public List<LogFileResource> GetLogFilesResponse()
|
||||||
|
{
|
||||||
|
var result = new List<LogFileResource>();
|
||||||
|
|
||||||
|
var files = GetLogFiles().ToList();
|
||||||
|
|
||||||
|
for (var i = 0; i < files.Count; i++)
|
||||||
|
{
|
||||||
|
var file = files[i];
|
||||||
|
var filename = Path.GetFileName(file);
|
||||||
|
|
||||||
|
result.Add(new LogFileResource
|
||||||
|
{
|
||||||
|
Id = i + 1,
|
||||||
|
Filename = filename,
|
||||||
|
LastWriteTime = _diskProvider.FileGetLastWrite(file),
|
||||||
|
ContentsUrl = string.Format("{0}/api/v1/{1}/{2}", _configFileProvider.UrlBase, _resource, filename),
|
||||||
|
DownloadUrl = string.Format("{0}/{1}/{2}", _configFileProvider.UrlBase, DownloadUrlRoot, filename)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.OrderByDescending(l => l.LastWriteTime).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet(@"{filename:regex([[-.a-zA-Z0-9]]+?\.txt)}")]
|
||||||
|
[Produces("text/plain")]
|
||||||
|
public IActionResult GetLogFileResponse(string filename)
|
||||||
|
{
|
||||||
|
LogManager.Flush();
|
||||||
|
|
||||||
|
var filePath = GetLogFilePath(filename);
|
||||||
|
|
||||||
|
if (!_diskProvider.FileExists(filePath))
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return PhysicalFile(filePath, "text/plain");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract IEnumerable<string> GetLogFiles();
|
||||||
|
protected abstract string GetLogFilePath(string filename);
|
||||||
|
|
||||||
|
protected abstract string DownloadUrlRoot { get; }
|
||||||
|
}
|
||||||
11
src/Sonarr.Api.V5/Logs/LogFileResource.cs
Normal file
11
src/Sonarr.Api.V5/Logs/LogFileResource.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using Sonarr.Http.REST;
|
||||||
|
|
||||||
|
namespace Sonarr.Api.V5.Logs;
|
||||||
|
|
||||||
|
public class LogFileResource : RestResource
|
||||||
|
{
|
||||||
|
public required string Filename { get; set; }
|
||||||
|
public required DateTime LastWriteTime { get; set; }
|
||||||
|
public required string ContentsUrl { get; set; }
|
||||||
|
public required string DownloadUrl { get; set; }
|
||||||
|
}
|
||||||
49
src/Sonarr.Api.V5/Logs/UpdateLogFileController.cs
Normal file
49
src/Sonarr.Api.V5/Logs/UpdateLogFileController.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using NzbDrone.Common.Disk;
|
||||||
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
|
using NzbDrone.Core.Configuration;
|
||||||
|
using Sonarr.Http;
|
||||||
|
|
||||||
|
namespace Sonarr.Api.V5.Logs;
|
||||||
|
|
||||||
|
[V5ApiController("log/file/update")]
|
||||||
|
public class UpdateLogFileController : LogFileControllerBase
|
||||||
|
{
|
||||||
|
private readonly IAppFolderInfo _appFolderInfo;
|
||||||
|
private readonly IDiskProvider _diskProvider;
|
||||||
|
|
||||||
|
public UpdateLogFileController(IAppFolderInfo appFolderInfo,
|
||||||
|
IDiskProvider diskProvider,
|
||||||
|
IConfigFileProvider configFileProvider)
|
||||||
|
: base(diskProvider, configFileProvider, "update")
|
||||||
|
{
|
||||||
|
_appFolderInfo = appFolderInfo;
|
||||||
|
_diskProvider = diskProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IEnumerable<string> GetLogFiles()
|
||||||
|
{
|
||||||
|
if (!_diskProvider.FolderExists(_appFolderInfo.GetUpdateLogFolder()))
|
||||||
|
{
|
||||||
|
return Enumerable.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _diskProvider.GetFiles(_appFolderInfo.GetUpdateLogFolder(), false)
|
||||||
|
.Where(f => Regex.IsMatch(Path.GetFileName(f), LOGFILE_ROUTE.TrimStart('/'), RegexOptions.IgnoreCase))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetLogFilePath(string filename)
|
||||||
|
{
|
||||||
|
return Path.Combine(_appFolderInfo.GetUpdateLogFolder(), filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string DownloadUrlRoot
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "updatelogfile";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user