Improvement. Fix broken symlink automatically.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-11-29 17:03:42 +02:00
parent 9a6934ae59
commit 097af11a6d

View File

@ -150,7 +150,8 @@ void SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool
to = to + QLatin1String(".lnk");
#endif
if (QFile::exists(to))
QFileInfo fileTo(to);
if (not fileTo.isSymLink() && fileTo.exists())
{
if (replaceOnConflit)
{
@ -161,6 +162,21 @@ void SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool
continue;
}
}
else if (fileTo.isSymLink())
{
if (not fileTo.exists())
{ // automatically fix broken symlink
QFile::remove(to);
}
else if (replaceOnConflit)
{
QFile::remove(to);
}
else
{
continue;
}
}
QFile::link(from, to);
}