From ca1f44ffa9b2c50526536f0e12ff69fafb0e80dd Mon Sep 17 00:00:00 2001 From: APTX Date: Mon, 1 Apr 2013 15:35:11 +0200 Subject: [PATCH] Check permissions for rename --- localmylist/renamehandler.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/localmylist/renamehandler.cpp b/localmylist/renamehandler.cpp index a0b6c83..3e1b6b7 100644 --- a/localmylist/renamehandler.cpp +++ b/localmylist/renamehandler.cpp @@ -133,7 +133,32 @@ void RenameHandler::handleRename() } } - // TODO check permissions + // TODO make sure these are the correct permissions + if (!QFileInfo(newFilePath).isWritable()) + { + fl.failedRename = true; + db->setFileLocation(fl); + db->log(tr("Rename: Failed to rename file <%1>. Destination directory <%2> is not writable.").arg(oldFile.canonicalFilePath()).arg(newFile.absolutePath()), 2); + continue; + } + + if (!QFileInfo(oldFile.absolutePath()).isWritable()) + { + fl.failedRename = true; + db->setFileLocation(fl); + db->log(tr("Rename: Failed to rename file <%1>. File directory is not writable.").arg(oldFile.canonicalFilePath()), 2); + continue; + } + +#ifdef Q_OS_WIN + if (!oldFile.isWritable()) + { + fl.failedRename = true; + db->setFileLocation(fl); + db->log(tr("Rename: Failed to rename file <%1>. File is not writable.").arg(oldFile.canonicalFilePath()), 2); + continue; + } +#endif if (!QFile::rename(oldFile.canonicalFilePath(), newFileString)) { -- 2.52.0