]> Some of my projects - aniplayer-old.git/commitdiff
Misc fixes.
authorAPTX <marek321@gmail.com>
Fri, 26 Feb 2010 01:07:02 +0000 (02:07 +0100)
committerAPTX <marek321@gmail.com>
Fri, 26 Feb 2010 01:07:02 +0000 (02:07 +0100)
lib/anidbudpclient/file.cpp

index af72b78f8256808fc875febf14e39f3fea53004e..e27592bafab50d8469a4c059286e1c51e53dccae 100644 (file)
@@ -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)