From b80a73aa3da19855782b52c45988918838f9230c Mon Sep 17 00:00:00 2001 From: APTX Date: Fri, 26 Feb 2010 02:07:02 +0100 Subject: [PATCH] Misc fixes. --- file.cpp | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/file.cpp b/file.cpp index af72b78..e27592b 100644 --- a/file.cpp +++ b/file.cpp @@ -26,6 +26,16 @@ File::~File() delete fileCommand; fileCommand = 0; } + if (addCommand) + { + delete addCommand; + addCommand = 0; + } + if (hashResult) + { + delete hashResult; + hashResult = 0; + } } QFileInfo File::file() const @@ -144,7 +154,7 @@ qDebug() << "finishRenaming"; if (name.isEmpty()) name = fileCommand->value(FileAnimeFlag::EnglishName).toString(); - QString fileName = tr("%1 - %2 - %3 - [%4](%5).%6") + QString newFileName = tr("%1 - %2 - %3 - [%4](%5).%6") .arg(name) .arg(fileCommand->value(FileAnimeFlag::EpNo).toString()) .arg(fileCommand->value(FileAnimeFlag::EpName).toString()) @@ -152,22 +162,29 @@ qDebug() << "finishRenaming"; .arg(fileCommand->value(FileFlag::Crc32).toString()) .arg(fileCommand->value(FileFlag::FileType).toString()); - fileName.replace('"', "'"); - fileName.replace(QRegExp("[\\/]"), "-"); - fileName.replace(QRegExp("[\\/:*?\"<>|]"), ""); -qDebug() << fileName; + newFileName.replace('"', "'"); + newFileName.replace(QRegExp("[\\/]"), "-"); + newFileName.replace(QRegExp("[\\/:*?\"<>|]"), ""); +qDebug() << newFileName; - QFile f(m_file.absoluteFilePath()); - if (f.rename(m_file.absolutePath() + "/" + fileName)) + QFile file(m_file.absoluteFilePath()); + + if (file.fileName() == newFileName) + { + updateStatus(Renaming, Success); + return; + } + + if (file.rename(m_file.absolutePath() + "/" + newFileName)) { - m_file.setFile(f); + m_file.setFile(file); qDebug() << m_file.absoluteFilePath(); updateStatus(Renaming, Success); } else { -qDebug() << f.errorString(); +qDebug() << file.errorString(); updateStatus(Renaming, Failure); } } @@ -325,7 +342,7 @@ void File::init() m_hashingState = m_renamingState = m_addingState = m_markingState = NotStarted; notWorking = true; - connect(this, SIGNAL(statusUpdate(Action,ActionState)), this, SLOT(workOnFinished(Action,ActionState))); + connect(this, SIGNAL(statusUpdate(AniDBUdpClient::File::Action,AniDBUdpClient::File::ActionState)), this, SLOT(workOnFinished(AniDBUdpClient::File::Action,AniDBUdpClient::File::ActionState))); } bool File::canContinue(ActionState state) -- 2.52.0