13#include <QMutexLocker>
41 LOG(VB_FILE, LOG_DEBUG,
"Spawning new delete thread.");
48 std::this_thread::sleep_for(500ms);
55 QList<DeleteHandler*>::iterator i;
65 LOG(VB_FILE, LOG_DEBUG,
"Delete thread self-terminating due to idle.");
74 QFileInfo finfo(path);
114 QString path = handler->
m_path;
115 QByteArray cpath_ba = handler->
m_path.toLocal8Bit();
116 const char *cpath = cpath_ba.constData();
118 QFileInfo finfo(handler->
m_path);
119 if (finfo.isSymLink())
130 LOG(VB_GENERAL, LOG_ERR,
131 QString(
"Error deleting '%1' -> '%2': ")
147 handler->
m_path = tmppath;
148 cpath_ba = handler->
m_path.toLocal8Bit();
149 cpath = cpath_ba.constData();
157 LOG(VB_GENERAL, LOG_ERR,
158 QString(
"Error deleting '%1': count not unlink ")
173 LOG(VB_FILE, LOG_INFO, QString(
"About to unlink/delete file: '%1'")
175 int fd = open(cpath, O_WRONLY);
178 LOG(VB_FILE, LOG_INFO, QString(
"About to unlink/delete file"));
183 LOG(VB_GENERAL, LOG_ERR,
184 QString(
"Error deleting '%1': is no directory ")
193 else if (unlink(cpath))
195 LOG(VB_GENERAL, LOG_ERR,
196 QString(
"Error deleting '%1': could not unlink ")
208 handler->
m_size = finfo.size();
209 handler->
m_wait = ctime.addSecs(3);
231 if (handler->
m_wait > ctime)
237 int err = ftruncate(handler->
m_fd, handler->
m_size);
241 LOG(VB_GENERAL, LOG_ERR, QString(
"Error truncating '%1'")
virtual void DeleteSucceeded(void)
virtual void DeleteFailed(void)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
QList< DeleteHandler * > m_newfiles
QList< DeleteHandler * > m_files
bool AddFile(const QString &path)
This is a wrapper around QThread that does several additional things.
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
int GetNumSetting(const QString &key, int defaultval=0)
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
virtual int IncrRef(void)
Increments reference count.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
bool MythRemoveDirectory(QDir &aDir)
QString getSymlinkTarget(const QString &start_file, QStringList *intermediaries, unsigned maxLinks)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.