From: APTX Date: Mon, 1 Apr 2013 13:35:11 +0000 (+0200) Subject: Check permissions for rename X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=ca1f44ffa9b2c50526536f0e12ff69fafb0e80dd;p=localmylist.git Check permissions for rename --- 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)) {