From feea50d8886eb9c03d219486f47509cc4b040e6e Mon Sep 17 00:00:00 2001 From: Le Tan Date: Fri, 8 Jun 2018 20:00:20 +0800 Subject: [PATCH] FileList: bug fix when importing the same note file in the same folder --- src/vfile.cpp | 5 ++++- src/vfilelist.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/vfile.cpp b/src/vfile.cpp index 8ea85069..5bdc4deb 100644 --- a/src/vfile.cpp +++ b/src/vfile.cpp @@ -44,7 +44,10 @@ bool VFile::open() Q_ASSERT(m_content.isEmpty()); QString filePath = fetchPath(); - Q_ASSERT(QFileInfo::exists(filePath)); + if (!QFileInfo::exists(filePath)) { + return false; + } + m_content = VUtils::readFileFromDisk(filePath); m_lastModified = QFileInfo(filePath).lastModified(); m_opened = true; diff --git a/src/vfilelist.cpp b/src/vfilelist.cpp index 46bd1c12..568e5bb7 100644 --- a/src/vfilelist.cpp +++ b/src/vfilelist.cpp @@ -771,6 +771,16 @@ bool VFileList::importFiles(const QStringList &p_files, QString *p_errMsg) bool copyNeeded = true; if (VUtils::equalPath(dirPath, fi.absolutePath())) { + // Check if it is already a note. + if (m_directory->findFile(name, false)) { + VUtils::addErrMsg(p_errMsg, tr("Skip importing file %1. " + "A note with the same name (case-insensitive) " + "in the same directory already exists.") + .arg(file)); + ret = false; + continue; + } + qDebug() << "skip cpoy file" << file << "locates in" << dirPath; copyNeeded = false; }