FileList: bug fix when importing the same note file in the same folder

This commit is contained in:
Le Tan 2018-06-08 20:00:20 +08:00
parent 88d719bb28
commit feea50d888
2 changed files with 14 additions and 1 deletions

View File

@ -44,7 +44,10 @@ bool VFile::open()
Q_ASSERT(m_content.isEmpty()); Q_ASSERT(m_content.isEmpty());
QString filePath = fetchPath(); QString filePath = fetchPath();
Q_ASSERT(QFileInfo::exists(filePath)); if (!QFileInfo::exists(filePath)) {
return false;
}
m_content = VUtils::readFileFromDisk(filePath); m_content = VUtils::readFileFromDisk(filePath);
m_lastModified = QFileInfo(filePath).lastModified(); m_lastModified = QFileInfo(filePath).lastModified();
m_opened = true; m_opened = true;

View File

@ -771,6 +771,16 @@ bool VFileList::importFiles(const QStringList &p_files, QString *p_errMsg)
bool copyNeeded = true; bool copyNeeded = true;
if (VUtils::equalPath(dirPath, fi.absolutePath())) { 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; qDebug() << "skip cpoy file" << file << "locates in" << dirPath;
copyNeeded = false; copyNeeded = false;
} }