Improvement. Fix broken symlink automatically.
--HG-- branch : develop
This commit is contained in:
parent
9a6934ae59
commit
097af11a6d
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user