Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/source/archivemanager/archivemanager.cpp

Large diffs are not rendered by default.

36 changes: 35 additions & 1 deletion src/source/archivemanager/batchjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,69 +24,89 @@ BatchJob::~BatchJob()

bool BatchJob::addSubjob(ArchiveJob *job)
{
qDebug() << "Adding subjob to BatchJob";
if (nullptr == job || m_listSubjobs.contains(job)) {
qWarning() << "Cannot add subjob - null job or already exists";
return false;
}

job->setParent(this);
m_listSubjobs.append(job);
qDebug() << "Subjob added successfully, total subjobs:" << m_listSubjobs.count();
return true;
}

bool BatchJob::removeSubjob(ArchiveJob *job)
{
qDebug() << "Removing subjob from BatchJob";
if (m_listSubjobs.removeAll(job) > 0) {
job->setParent(nullptr);
delete job;
qDebug() << "Subjob removed successfully, remaining subjobs:" << m_listSubjobs.count();
return true;
}

qWarning() << "Failed to remove subjob - not found";
return false;
}

bool BatchJob::hasSubjobs() const
{
qDebug() << "Checking if BatchJob has subjobs, count:" << m_listSubjobs.count();
return !m_listSubjobs.isEmpty();
}

const QList<ArchiveJob *> &BatchJob::subjobs() const
{
// qDebug() << "Getting subjobs list, count:" << m_listSubjobs.count();
return m_listSubjobs;
}

void BatchJob::clearSubjobs()
{
qDebug() << "Clearing all subjobs, count:" << m_listSubjobs.count();
Q_FOREACH (ArchiveJob *job, m_listSubjobs) {
job->setParent(nullptr);
delete job;
}

m_listSubjobs.clear();
qDebug() << "All subjobs cleared";
}

void BatchJob::doPause()
{
qDebug() << "Pausing BatchJob";
// 调用子job暂停接口
if (m_pCurJob) {
qDebug() << "Pausing current subjob";
m_pCurJob->doPause();
} else {
qWarning() << "No current subjob to pause";
}
}

void BatchJob::doContinue()
{
qDebug() << "Continuing BatchJob";
// 调用子job继续接口
if (m_pCurJob) {
qDebug() << "Continuing current subjob";
m_pCurJob->doContinue();
} else {
qWarning() << "No current subjob to continue";
}
}

bool BatchJob::status()
{
qDebug() << "Getting BatchJob status";
// 调用子job继续接口
if (m_pCurJob) {
return m_pCurJob->status();
}

qWarning() << "No current subjob to get status";
return false;
}

Expand All @@ -99,7 +119,7 @@ BatchExtractJob::BatchExtractJob(QObject *parent)

BatchExtractJob::~BatchExtractJob()
{

// qDebug() << "BatchExtractJob instance destroyed";
}

void BatchExtractJob::start()
Expand Down Expand Up @@ -151,14 +171,17 @@ bool BatchExtractJob::setArchiveFiles(const QStringList &listFile)

bool BatchExtractJob::addExtractItem(const QFileInfo &fileInfo)
{
qDebug() << "Adding extract item for file:" << fileInfo.fileName();
QString strName = fileInfo.filePath();
UnCompressParameter::SplitType eType = UnCompressParameter::ST_No;
UiTools::transSplitFileName(strName, eType);
UiTools::AssignPluginType ePluginType = (UnCompressParameter::ST_Zip == eType) ?
(UiTools::AssignPluginType::APT_Cli7z) : (UiTools::AssignPluginType::APT_Auto);
qDebug() << "Creating interface for extract item";
ReadOnlyArchiveInterface *pIface = UiTools::createInterface(fileInfo.filePath(), false, ePluginType);

if (pIface) {
qDebug() << "Interface created successfully, setting up extraction options";
// 创建解压参数
ExtractionOptions stOptions;
stOptions.strTargetPath = m_strExtractPath;
Expand Down Expand Up @@ -187,29 +210,34 @@ bool BatchExtractJob::addExtractItem(const QFileInfo &fileInfo)
// tar.7z特殊处理,右键解压缩到当前文件夹使用cli7zplugin
if (strName.endsWith(QLatin1String(".tar.7z"))
&& determineMimeType(strName).name() == QLatin1String("application/x-7z-compressed")) {
qDebug() << "Detected tar.7z archive, using special handling";
stOptions.bTar_7z = true;
ePluginType = UiTools::AssignPluginType::APT_Cli7z;
}

pIface->setParent(this); // 跟随BatchExtractJob释放
if (!stOptions.bTar_7z) {
qDebug() << "Creating ExtractJob for regular archive";
ExtractJob *pExtractJob = new ExtractJob(QList<FileEntry>(), pIface, stOptions);
connect(pExtractJob, &ExtractJob::signalprogress, this, &BatchExtractJob::slotHandleSingleJobProgress);
connect(pExtractJob, &ExtractJob::signalCurFileName, this, &BatchExtractJob::slotHandleSingleJobCurFileName);
connect(pExtractJob, &ExtractJob::signalQuery, this, &BatchExtractJob::signalQuery);
connect(pExtractJob, &ExtractJob::signalJobFinshed, this, &BatchExtractJob::slotHandleSingleJobFinished);
addSubjob(pExtractJob);
} else {
qDebug() << "Creating StepExtractJob for tar.7z archive";
StepExtractJob *pStepExtractJob = new StepExtractJob(fileInfo.absoluteFilePath(), stOptions);
connect(pStepExtractJob, &StepExtractJob::signalprogress, this, &BatchExtractJob::slotHandleSingleJobProgress);
connect(pStepExtractJob, &StepExtractJob::signalCurFileName, this, &BatchExtractJob::slotHandleSingleJobCurFileName);
connect(pStepExtractJob, &StepExtractJob::signalQuery, this, &BatchExtractJob::signalQuery);
connect(pStepExtractJob, &StepExtractJob::signalJobFinshed, this, &BatchExtractJob::slotHandleSingleJobFinished);
addSubjob(pStepExtractJob);
}
qDebug() << "Extract item added successfully";
return true;
}

qWarning() << "Failed to create interface for extract item";
return false;
}

Expand All @@ -218,16 +246,19 @@ void BatchExtractJob::slotHandleSingleJobProgress(double dPercentage)
QFileInfo fileInfo(m_listFiles[m_iCurArchiveIndex]);
qint64 qCurSize = fileInfo.size(); // 当前解压的压缩包大小
double dProgress = double(qCurSize) * dPercentage / m_qBatchTotalSize + m_dLastPercentage;
qDebug() << "Batch job progress:" << dProgress << "%, current file:" << fileInfo.fileName();
emit signalprogress(dProgress);
}

void BatchExtractJob::slotHandleSingleJobCurFileName(const QString &strName)
{
qDebug() << "Current file being processed:" << strName;
emit signalCurFileName(strName);
}

void BatchExtractJob::slotHandleSingleJobFinished()
{
qDebug() << "Single job finished handler called";
if (m_pCurJob != nullptr) {
qDebug() << "Single job finished - Type:" << m_pCurJob->m_eJobType
<< "Result:" << m_pCurJob->m_eFinishedType;
Expand All @@ -245,6 +276,7 @@ void BatchExtractJob::slotHandleSingleJobFinished()
}

// 移除当前job
qDebug() << "Removing completed subjob";
removeSubjob(m_pCurJob);

if (!hasSubjobs()) {
Expand All @@ -263,5 +295,7 @@ void BatchExtractJob::slotHandleSingleJobFinished()
m_pCurJob = subjobs().at(0);
m_pCurJob->start();
}
} else {
qWarning() << "No current job to handle";
}
}
Loading