2020-09-30 23:28:47 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
|
|
|
|
SPDX-FileCopyrightText: 2012-2018 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
SPDX-FileCopyrightText: 2016 Teo Mrnjavac <teo@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
#include "ops/backupoperation.h"
|
|
|
|
|
|
|
|
#include "core/partition.h"
|
|
|
|
#include "core/device.h"
|
|
|
|
|
|
|
|
#include "jobs/backupfilesystemjob.h"
|
|
|
|
|
|
|
|
#include "util/capacity.h"
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
|
|
|
/** Creates a new BackupOperation.
|
2015-07-13 15:16:36 +01:00
|
|
|
@param d the Device where the FileSystem to back up is on
|
|
|
|
@param p the Partition where the FileSystem to back up is in
|
|
|
|
@param filename the name of the file to back up to
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
|
|
|
BackupOperation::BackupOperation(Device& d, Partition& p, const QString& filename) :
|
2015-07-13 15:16:36 +01:00
|
|
|
Operation(),
|
|
|
|
m_TargetDevice(d),
|
|
|
|
m_BackupPartition(p),
|
|
|
|
m_FileName(filename),
|
|
|
|
m_BackupJob(new BackupFileSystemJob(targetDevice(), backupPartition(), fileName()))
|
2015-06-04 01:29:22 +01:00
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
addJob(backupJob());
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString BackupOperation::description() const
|
|
|
|
{
|
2016-07-17 23:41:00 +01:00
|
|
|
return xi18nc("@info:status", "Backup partition <filename>%1</filename> (%2, %3) to <filename>%4</filename>", backupPartition().deviceNode(), Capacity::formatByteSize(backupPartition().capacity()), backupPartition().fileSystem().name(), fileName());
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Can the given Partition be backed up?
|
2015-07-22 14:48:03 +01:00
|
|
|
@param p The Partition in question, may be nullptr.
|
2015-07-13 15:16:36 +01:00
|
|
|
@return true if @p p can be backed up.
|
2015-06-04 01:29:22 +01:00
|
|
|
*/
|
|
|
|
bool BackupOperation::canBackup(const Partition* p)
|
|
|
|
{
|
2015-07-22 14:48:03 +01:00
|
|
|
if (p == nullptr)
|
2015-07-13 15:16:36 +01:00
|
|
|
return false;
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
if (p->isMounted())
|
|
|
|
return false;
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2018-04-09 03:46:05 +01:00
|
|
|
if (p->state() == Partition::State::New || p->state() == Partition::State::Copy || p->state() == Partition::State::Restore)
|
2015-07-13 15:16:36 +01:00
|
|
|
return false;
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return p->fileSystem().supportBackup() != FileSystem::cmdSupportNone;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|