Skip to content

Commit

Permalink
make PlaybackSock::GetDiskSpace() return a FileSystemInfoList
Browse files Browse the repository at this point in the history
also remove unused EncoderLink::GetDiskSpace().
  • Loading branch information
ulmus-scott committed Jan 29, 2025
1 parent bf6211f commit 19830fe
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 38 deletions.
14 changes: 0 additions & 14 deletions mythtv/programs/mythbackend/encoderlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,20 +340,6 @@ bool EncoderLink::CheckFile(ProgramInfo *pginfo)
return pginfo->IsLocal();
}

/**
* \brief Appends total and used disk space in Kilobytes
*
* \param o_strlist list to append to
*/
void EncoderLink::GetDiskSpace(QStringList &o_strlist)
{
if (HasSockAndIncrRef())
{
ReferenceLocker rlocker(m_sock);
m_sock->GetDiskSpace(o_strlist);
}
}

/** \fn EncoderLink::GetMaxBitrate()
* \brief Returns maximum bits per second this recorder might output.
*
Expand Down
1 change: 0 additions & 1 deletion mythtv/programs/mythbackend/encoderlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class EncoderLink
bool IsTunerLocked(void) const { return m_locked; }

bool CheckFile(ProgramInfo *pginfo);
void GetDiskSpace(QStringList &o_strlist);
long long GetMaxBitrate(void);
std::chrono::milliseconds SetSignalMonitoringRate(std::chrono::milliseconds rate, int notifyFrontend);

Expand Down
25 changes: 8 additions & 17 deletions mythtv/programs/mythbackend/mainserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5134,7 +5134,6 @@ void MainServer::BackendQueryDiskSpace(QStringList &strlist, bool consolidated,
{
FileSystemInfoList fsInfos = FileServerHandler::QueryFileSystems();
QString allHostList;
QStringList tmplist;
if (allHosts)
{
allHostList = gCoreContext->GetHostName();
Expand All @@ -5160,29 +5159,21 @@ void MainServer::BackendQueryDiskSpace(QStringList &strlist, bool consolidated,
m_sockListLock.unlock();

for (auto & pbs : localPlaybackList) {
pbs->GetDiskSpace(tmplist); // QUERY_FREE_SPACE
fsInfos << pbs->GetDiskSpace(); // QUERY_FREE_SPACE
pbs->DecrRef();
}
}

if (!consolidated)
if (consolidated)
{
strlist << FileSystemInfoManager::ToStringList(fsInfos) << tmplist;
return;
}

fsInfos.append(FileSystemInfoManager::FromStringList(tmplist));
tmplist.clear(); // not used after this point
strlist.clear();
// Consolidate hosts sharing storage
int64_t maxWriteFiveSec = GetCurrentMaxBitrate()/12 /*5 seconds*/;
maxWriteFiveSec = std::max((int64_t)2048, maxWriteFiveSec); // safety for NFS mounted dirs

// Consolidate hosts sharing storage
int64_t maxWriteFiveSec = GetCurrentMaxBitrate()/12 /*5 seconds*/;
maxWriteFiveSec = std::max((int64_t)2048, maxWriteFiveSec); // safety for NFS mounted dirs

FileSystemInfoManager::Consolidate(fsInfos, true, maxWriteFiveSec, allHostList);
FileSystemInfoManager::Consolidate(fsInfos, true, maxWriteFiveSec, allHostList);
}

// Pass the cleaned list back
strlist << FileSystemInfoManager::ToStringList(fsInfos);
strlist = FileSystemInfoManager::ToStringList(fsInfos);
}

void MainServer::GetFilesystemInfos(FileSystemInfoList &fsInfos,
Expand Down
11 changes: 6 additions & 5 deletions mythtv/programs/mythbackend/playbacksock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,17 @@ bool PlaybackSock::GoToSleep(void)
}

/**
* \brief Appends host's dir's total and used space in kilobytes.
* \brief Gets the total and used space in kilobytes for the host's directories.
*/
void PlaybackSock::GetDiskSpace(QStringList &o_strlist)
FileSystemInfoList PlaybackSock::GetDiskSpace()
{
QStringList strlist(QString("QUERY_FREE_SPACE")); // should this be ..._SUMMARY? based on the comment above
QStringList strlist(QString("QUERY_FREE_SPACE"));

if (SendReceiveStringList(strlist, 8)) // TODO replace magic numbers FileSystemInfo::k_lines; return a list of FileSystemInfos instead?
if (SendReceiveStringList(strlist, FileSystemInfo::k_lines))
{
o_strlist += strlist;
return FileSystemInfoManager::FromStringList(strlist);
}
return {};
}

int PlaybackSock::CheckRecordingActive(const ProgramInfo *pginfo)
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythbackend/playbacksock.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QMutex>
#include <QSize>

#include "libmythbase/filesysteminfo.h"
#include "libmythbase/programinfo.h" // ProgramInfo
#include "libmythbase/programtypes.h" // RecStatus::Type
#include "libmythbase/referencecounter.h"
Expand Down Expand Up @@ -60,7 +61,7 @@ class PlaybackSock : public ReferenceCounter
QString getIP(void) const { return m_ip; }

bool GoToSleep(void);
void GetDiskSpace(QStringList &o_strlist);
FileSystemInfoList GetDiskSpace();
int DeleteFile(const QString &filename, const QString &sgroup);
int StopRecording(const ProgramInfo *pginfo);
int CheckRecordingActive(const ProgramInfo *pginfo);
Expand Down

0 comments on commit 19830fe

Please sign in to comment.