File indexing completed on 2024-04-28 09:41:43
0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com> 0002 // 0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 0005 #ifndef FSEXECUTOR_H 0006 #define FSEXECUTOR_H 0007 0008 #include "planexecutor.h" 0009 0010 #include <QThread> 0011 0012 class BackupPlan; 0013 class KDirWatch; 0014 class QTimer; 0015 0016 // KDirWatch (well, inotify) does not detect when something gets mounted on a watched directory. 0017 // work around this problem by monitoring the mounts of the system in a separate thread. 0018 class MountWatcher: public QThread { 0019 Q_OBJECT 0020 0021 signals: 0022 void mountsChanged(); 0023 0024 protected: 0025 void run() override; 0026 }; 0027 0028 0029 // Plan executor that stores the backup to a path in the local 0030 // filesystem, uses KDirWatch to monitor for when the folder 0031 // becomes available/unavailable. Can be used for external 0032 // drives or networked filesystems if you always mount it at 0033 // the same mountpoint. 0034 class FSExecutor: public PlanExecutor 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 FSExecutor(BackupPlan *pPlan, KupDaemon *pKupDaemon); 0040 ~FSExecutor() override; 0041 0042 public slots: 0043 void checkStatus() override; 0044 0045 protected slots: 0046 void checkMountPoints(); 0047 0048 protected: 0049 QString mWatchedParentDir; 0050 KDirWatch *mDirWatch; 0051 MountWatcher mMountWatcher; 0052 }; 0053 0054 #endif // FSEXECUTOR_H