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; }