51 lines
1.2 KiB
C++
Executable File
51 lines
1.2 KiB
C++
Executable File
/**
|
|
* Helper class to remove outdated telegram files in a directory
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2016-09-26
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <NGLLogger/INGLLogger.h>
|
|
|
|
class QThread;
|
|
class XDR_Wrapper_it;
|
|
namespace TetraRadio
|
|
{
|
|
class DirectoryCleanerWorker;
|
|
class DirectoryCleaner : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
DirectoryCleaner(const QString &directory, unsigned int maxAgeSec, QObject *parent = nullptr);
|
|
~DirectoryCleaner();
|
|
private:
|
|
// remove xdr telegrams which are regenerated on startup (e.g. AES telegrams)
|
|
// and therefore must not be reread on startup
|
|
void doInitialCleanup(const QString &directory);
|
|
bool teleShouldBeRemoved(int teleId);
|
|
QThread *m_cleanerThread;
|
|
DirectoryCleanerWorker *m_worker;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
class DirectoryCleanerWorker: public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
DirectoryCleanerWorker(const QString &directory, unsigned int maxAgeSec);
|
|
~DirectoryCleanerWorker() = default;
|
|
public Q_SLOTS:
|
|
void onTimeout();
|
|
private:
|
|
void doCleanup();
|
|
private:
|
|
QString m_directory;
|
|
qint64 m_maxAgeSec;
|
|
bool m_bWarnedOnce;
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
} // namespace TetraRadio
|