diff --git a/daemon/remote/XmlRpc.cpp b/daemon/remote/XmlRpc.cpp index 9c300eec..530dd8eb 100644 --- a/daemon/remote/XmlRpc.cpp +++ b/daemon/remote/XmlRpc.cpp @@ -1303,6 +1303,12 @@ void StatusXmlCommand::Execute() "TotalDiskSpaceLo%u\n" "TotalDiskSpaceHi%u\n" "TotalDiskSpaceMB%i\n" + "FreeInterDiskSpaceLo%u\n" + "FreeInterDiskSpaceHi%u\n" + "FreeInterDiskSpaceMB%i\n" + "TotalInterDiskSpaceLo%u\n" + "TotalInterDiskSpaceHi%u\n" + "TotalInterDiskSpaceMB%i\n" "ServerTime%i\n" "ResumeTime%i\n" "FeedActive%s\n" @@ -1359,6 +1365,12 @@ void StatusXmlCommand::Execute() "\"TotalDiskSpaceLo\" : %u,\n" "\"TotalDiskSpaceHi\" : %u,\n" "\"TotalDiskSpaceMB\" : %i,\n" + "\"FreeInterDiskSpaceLo\" : %u,\n" + "\"FreeInterDiskSpaceHi\" : %u,\n" + "\"FreeInterDiskSpaceMB\" : %i,\n" + "\"TotalInterDiskSpaceLo\" : %u,\n" + "\"TotalInterDiskSpaceHi\" : %u,\n" + "\"TotalInterDiskSpaceMB\" : %i,\n" "\"ServerTime\" : %i,\n" "\"ResumeTime\" : %i,\n" "\"FeedActive\" : %s,\n" @@ -1442,19 +1454,55 @@ void StatusXmlCommand::Execute() uint32 freeDiskSpaceHi, freeDiskSpaceLo; uint32 totalDiskSpaceHi, totalDiskSpaceLo; + uint32 freeInterDiskSpaceHi, freeInterDiskSpaceLo; + uint32 totalInterDiskSpaceHi, totalInterDiskSpaceLo; + int64 freeDiskSpace = 0; int64 totalDiskSpace = 0; - auto res = FileSystem::GetDiskState(g_Options->GetDestDir()); - if (res.has_value()) + int64 freeInterDiskSpace = 0; + int64 totalInterDiskSpace = 0; + + if (Util::EmptyStr(g_Options->GetDestDir())) { - const auto& value = res.value(); - freeDiskSpace = value.available; - totalDiskSpace = value.total; + freeDiskSpace = 0; + totalDiskSpace = 0; } + else + { + auto res = FileSystem::GetDiskState(g_Options->GetDestDir()); + if (res.has_value()) + { + const auto& value = res.value(); + freeDiskSpace = value.available; + totalDiskSpace = value.total; + } + } + + if (Util::EmptyStr(g_Options->GetInterDir())) + { + freeInterDiskSpace = freeDiskSpace; + totalInterDiskSpace = totalDiskSpace; + } + else + { + auto res = FileSystem::GetDiskState(g_Options->GetInterDir()); + if (res.has_value()) + { + const auto& value = res.value(); + freeInterDiskSpace = value.available; + totalInterDiskSpace = value.total; + } + } + Util::SplitInt64(freeDiskSpace, &freeDiskSpaceHi, &freeDiskSpaceLo); Util::SplitInt64(totalDiskSpace, &totalDiskSpaceHi, &totalDiskSpaceLo); + Util::SplitInt64(freeInterDiskSpace, &freeInterDiskSpaceHi, &freeInterDiskSpaceLo); + Util::SplitInt64(totalInterDiskSpace, &totalInterDiskSpaceHi, &totalInterDiskSpaceLo); + int freeDiskSpaceMB = static_cast(freeDiskSpace / 1024 / 1024); int totalDiskSpaceMB = static_cast(totalDiskSpace / 1024 / 1024); + int freeInterDiskSpaceMB = static_cast(freeInterDiskSpace / 1024 / 1024); + int totalInterDiskSpaceMB = static_cast(totalInterDiskSpace / 1024 / 1024); int serverTime = (int)Util::CurrentTime(); int resumeTime = (int)g_WorkState->GetResumeTime(); @@ -1482,6 +1530,12 @@ void StatusXmlCommand::Execute() totalDiskSpaceLo, totalDiskSpaceHi, totalDiskSpaceMB, + freeInterDiskSpaceLo, + freeInterDiskSpaceHi, + freeInterDiskSpaceMB, + totalInterDiskSpaceLo, + totalInterDiskSpaceHi, + totalInterDiskSpaceMB, serverTime, resumeTime, BoolToStr(feedActive), queuedScripts); int index = 0; diff --git a/docs/api/STATUS.md b/docs/api/STATUS.md index b5d726d6..460cbf0f 100644 --- a/docs/api/STATUS.md +++ b/docs/api/STATUS.md @@ -58,6 +58,12 @@ This method returns structure with following fields: - **TotalDiskSpaceLo** `(int)` - `v24.2` Total disk space on `DestDir`, in bytes. This field contains the low 32-bits of 64-bit value - **TotalDiskSpaceHi** `(int)` - `v24.2` Total disk space on `DestDir`, in bytes. This field contains the high 32-bits of 64-bit value - **TotalDiskSpaceMB** `(int)` - `v24.2` Total disk space on `DestDir`, in MiB. +- **FreeInterDiskSpaceLo** `(int)` - `v24.3` Free disk space on `InterDir`, in bytes. This field contains the low 32-bits of 64-bit value +- **FreeInterDiskSpaceHi** `(int)` - `v24.3` Free disk space on `InterDir`, in bytes. This field contains the high 32-bits of 64-bit value +- **FreeInterDiskSpaceMB** `(int)` - `v24.3` Free disk space on `InterDir`, in MiB. +- **TotalInterDiskSpaceLo** `(int)` - `v24.3` Total disk space on `InterDir`, in bytes. This field contains the low 32-bits of 64-bit value +- **TotalInterDiskSpaceHi** `(int)` - `v24.3` Total disk space on `InterDir`, in bytes. This field contains the high 32-bits of 64-bit value +- **TotalInterDiskSpaceMB** `(int)` - `v24.3` Total disk space on `InterDir`, in MiB. - **QueueScriptCount** `(int)` - Indicates number of queue-scripts queued for execution including the currently running. - **NewsServers** `(struct[])` - Status of news-servers, array of structures with following fields - **ID** `(int)` - Server number in the configuration file. For example `1` for server defined by options `Server1.Host`, `Server1.Port`, etc. diff --git a/webui/index.html b/webui/index.html index d090e28a..2a61fa22 100644 --- a/webui/index.html +++ b/webui/index.html @@ -729,13 +729,13 @@

System

Arch - - Free disk space - + + Free / Total disk space (DestDir) + - - Total disk space - + + Free / Total disk space (InterDir) + Write buffer diff --git a/webui/system-info.js b/webui/system-info.js index 15c36903..7a6d87d8 100644 --- a/webui/system-info.js +++ b/webui/system-info.js @@ -29,8 +29,10 @@ var SystemInfo = (new function($) var $SysInfo_CPUModel; var $SysInfo_Arch; var $SysInfo_IP; - var $SysInfo_FreeDiskSpace; - var $SysInfo_TotalDiskSpace; + var $SysInfo_DestDiskSpace; + var $SysInfo_InterDiskSpace; + var $SysInfo_DestDiskSpaceContainer; + var $SysInfo_InterDiskSpaceContainer; var $SysInfo_ArticleCache; var $SysInfo_WriteBuffer; var $SysInfo_ToolsTable; @@ -65,7 +67,19 @@ var SystemInfo = (new function($) update: function(status) { $SysInfo_Uptime.text(Util.formatTimeHMS(status['UpTimeSec'])); - renderDiskSpace(+status['FreeDiskSpaceMB'], +status['TotalDiskSpaceMB']); + + var destDirOpt = Options.findOption(Options.options, 'DestDir'); + var interDirOpt = Options.findOption(Options.options, 'InterDir'); + + + + if (destDirOpt && interDirOpt) + { + var destDirPath = destDirOpt.Value; + var interDistPath = interDirOpt.Value ? interDirOpt.Value : destDirPath; + renderDiskSpace(+status['FreeDiskSpaceMB'], +status['TotalDiskSpaceMB'], destDirPath); + renderInterDiskSpace(+status['FreeInterDiskSpaceMB'], +status['TotalInterDiskSpaceMB'], interDistPath); + } } } @@ -96,8 +110,10 @@ var SystemInfo = (new function($) $SysInfo_CPUModel = $('#SysInfo_CPUModel'); $SysInfo_Arch = $('#SysInfo_Arch'); $SysInfo_IP = $('#SysInfo_IP'); - $SysInfo_FreeDiskSpace = $('#SysInfo_FreeDiskSpace'); - $SysInfo_TotalDiskSpace = $('#SysInfo_TotalDiskSpace'); + $SysInfo_DestDiskSpace = $('#SysInfo_DestDiskSpace'); + $SysInfo_InterDiskSpace = $('#SysInfo_InterDiskSpace'); + $SysInfo_InterDiskSpaceContainer = $('#SysInfo_InterDiskSpaceContainer'); + $SysInfo_DestDiskSpaceContainer = $('#SysInfo_DestDiskSpaceContainer'); $SysInfo_ArticleCache = $('#SysInfo_ArticleCache'); $SysInfo_WriteBuffer = $('#SysInfo_WriteBuffer'); $SysInfo_ToolsTable = $('#SysInfo_ToolsTable'); @@ -136,6 +152,17 @@ var SystemInfo = (new function($) ); } + function pathsOnSameDisk(path1, path2) + { + path1 = path1.replace(/\\/g, '/'); + path2 = path2.replace(/\\/g, '/'); + + var drive1 = path1.match(/^[a-zA-Z]:\//i) ? path1.match(/^[a-zA-Z]:\//i)[0] : '/'; + var drive2 = path2.match(/^[a-zA-Z]:\//i) ? path2.match(/^[a-zA-Z]:\//i)[0] : '/'; + + return drive1 === drive2; + } + function hideSpinner() { $SystemInfo_Spinner.hide(); @@ -257,11 +284,22 @@ var SystemInfo = (new function($) }); } - function renderDiskSpace(free, total) + function renderDiskSpace(free, total, path) + { + $SysInfo_DestDiskSpace.text(formatDiskInfo(free, total)); + $SysInfo_DestDiskSpaceContainer.attr('title', path); + } + + function renderInterDiskSpace(free, total, path) + { + $SysInfo_InterDiskSpace.text(formatDiskInfo(free, total)); + $SysInfo_InterDiskSpaceContainer.attr('title', path); + } + + function formatDiskInfo(free, total) { var percents = total !== 0 ? (free / total * 100).toFixed(1) + '%' : '0.0%'; - $SysInfo_FreeDiskSpace.text(Util.formatSizeMB(free) + ' / ' + percents); - $SysInfo_TotalDiskSpace.text(Util.formatSizeMB(total)); + return Util.formatSizeMB(free) + ' (' + percents + ') / ' + Util.formatSizeMB(total); } function renderIP(network)