Skip to content

Commit 271cf66

Browse files
Rainer KellerRainer Keller
Rainer Keller
authored and
Rainer Keller
committed
Fix setting default application with invalid symlink
Change-Id: Ia99140c0a8f8cf201eeaad352c36becbb1f6636f Reviewed-by: Karim Pinter <[email protected]> Reviewed-by: Samuli Piippo <[email protected]>
1 parent 1e3c96e commit 271cf66

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

main.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,32 @@ bool parseConfigFileDirectory(Config *config, const QString &dirName)
245245

246246
static bool removeDefault()
247247
{
248-
if (QFile::exists(B2QT_PREFIX)) {
248+
QFileInfo fi(B2QT_PREFIX);
249+
250+
if (fi.isSymLink()) {
249251
if (!QFile::remove(B2QT_PREFIX)) {
250252
fprintf(stderr, "Could not remove default application.\n");
251253
return false;
252254
}
253255
sync();
256+
return true;
254257
}
255-
return true;
258+
259+
if (fi.isDir()) {
260+
fprintf(stderr, "Could not remove default application because '" B2QT_PREFIX "' is a directory. It should be a symlink.\n");
261+
return false;
262+
}
263+
264+
if (fi.isFile()) {
265+
fprintf(stderr, "Could not remove default application because '" B2QT_PREFIX "' is a file. It should be a symlink.\n");
266+
return false;
267+
}
268+
269+
if (!fi.exists()) {
270+
return true;
271+
}
272+
273+
return false;
256274
}
257275

258276
static bool makeDefault(const QString &filepath)

0 commit comments

Comments
 (0)