fix(utility): change sync folder display name when migrating.

Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
Camila Ayres 2025-08-14 12:10:27 +02:00 committed by Matthieu Gallien
parent cde75c0e38
commit fcd9d15754

View File

@ -190,9 +190,6 @@ QString Utility::syncFolderDisplayName(const QString &currentDisplayName, const
void Utility::migrateFavLink(const QString &folder)
{
//overwrite Desktop.ini, update icon
setupDesktopIni(folder, true);
const QDir folderDir(QDir::fromNativeSeparators(folder));
const auto oldDirName = folderDir.dirName();
const auto nextcloud = QStringLiteral("Nextcloud");
@ -201,6 +198,16 @@ void Utility::migrateFavLink(const QString &folder)
return;
}
const auto folderDisplayName = syncFolderDisplayName(oldDirName, QStringLiteral(APPLICATION_NAME));
// overwrite Desktop.ini, update icon, update folder display name
setupDesktopIni(folder, true);
QFile desktopIni(folder + QLatin1String("/Desktop.ini"));
desktopIni.open(QFile::WriteOnly);
desktopIni.write("\r\nLocalizedResourceName=");
desktopIni.write(folderDisplayName.toUtf8());
desktopIni.write("\r\n");
desktopIni.close();
const auto pathToLinks = systemPathToLinks();
if (pathToLinks.isEmpty()) {
qCWarning(lcUtility) << "SHGetKnownFolderPath for links has failed.";
@ -209,7 +216,7 @@ void Utility::migrateFavLink(const QString &folder)
const QDir dirPathToLinks(pathToLinks);
const auto oldLnkFilename = dirPathToLinks.filePath(oldDirName + QLatin1String(".lnk"));
const auto newLnkFilename = dirPathToLinks.filePath(syncFolderDisplayName(oldDirName, QStringLiteral(APPLICATION_NAME)) + QLatin1String(".lnk"));
const auto newLnkFilename = dirPathToLinks.filePath(folderDisplayName + QLatin1String(".lnk"));
if (QFile::exists(newLnkFilename)) {
qCWarning(lcUtility) << "New lnk file already exists" << newLnkFilename;