From fec438e49428e7aa984a5d5c079cd10469a91351 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 4 Feb 2018 11:55:16 +0300 Subject: [PATCH] [app] When renaming the folder, rename the config/cache directory too --- app/src/BooksShelf.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/BooksShelf.cpp b/app/src/BooksShelf.cpp index ffd5dc3..e343716 100644 --- a/app/src/BooksShelf.cpp +++ b/app/src/BooksShelf.cpp @@ -564,11 +564,19 @@ void BooksShelf::setName(QString aName) } newRelativePath += aName; - QString oldPath = iStorage.fullPath(iRelativePath); - QString newPath = iStorage.fullPath(newRelativePath); - + const QString oldPath = iStorage.fullPath(iRelativePath); + const QString newPath = iStorage.fullPath(newRelativePath); HDEBUG("renaming" << qPrintable(oldPath) << "->" << qPrintable(newPath)); if (rename(qPrintable(oldPath), qPrintable(newPath)) == 0) { + + // Rename the config/cache directory too + const QString oldConfPath = iStorage.fullConfigPath(iRelativePath); + const QString newConfPath = iStorage.fullConfigPath(newRelativePath); + HDEBUG(qPrintable(oldConfPath) << "->" << qPrintable(newConfPath)); + if (rename(qPrintable(oldConfPath), qPrintable(newConfPath))) { + HWARN(strerror(errno)); + } + const QString oldFileName(iFileName); iRelativePath = newRelativePath; iPath = iStorage.fullPath(iRelativePath); @@ -595,7 +603,7 @@ void BooksShelf::setName(QString aName) } } } else { - HDEBUG(strerror(errno)); + HWARN(strerror(errno)); } } }