File indexing completed on 2024-06-09 09:30:25

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 RESTOREJOB_H
0006 #define RESTOREJOB_H
0007 
0008 #include "versionlistmodel.h"
0009 
0010 #include <KJob>
0011 #include <KProcess>
0012 
0013 class RestoreJob : public KJob
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit RestoreJob(QString pRepositoryPath, QString pSourcePath, QString pRestorationPath,
0018                         int pTotalDirCount, qint64 pTotalFileSize, const QHash<QString, qint64> &pFileSizes);
0019     void start() override;
0020 
0021 protected slots:
0022     void slotRestoringStarted();
0023     void slotRestoringDone(int pExitCode, QProcess::ExitStatus pExitStatus);
0024 
0025 protected:
0026     void timerEvent(QTimerEvent *pTimerEvent) override;
0027     static void makeNice(int pPid);
0028     void moveFolder();
0029 
0030     KProcess mRestoreProcess;
0031     QString mRepositoryPath;
0032     QString mSourcePath;
0033     QString mRestorationPath;
0034     QString mSourceFileName;
0035     int mTotalDirCount;
0036     qint64 mTotalFileSize;
0037     const QHash<QString, qint64> &mFileSizes;
0038     int mTimerId{};
0039 };
0040 
0041 #endif // RESTOREJOB_H