summaryrefslogtreecommitdiffstats
path: root/filewidget.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-01-02 19:31:42 +0100
committerArno <arno@disconnect.de>2018-01-02 19:31:42 +0100
commitc77061d4d19de23c805ccbcc7cc229b221d4c1d5 (patch)
treeb947182bf298f61fbbf00d3cbca9a381ca870656 /filewidget.cpp
parent2f0262b6e762ee4ecb6bf058493ab73a391bab4e (diff)
downloadShemovCleaner-c77061d4d19de23c805ccbcc7cc229b221d4c1d5.tar.gz
ShemovCleaner-c77061d4d19de23c805ccbcc7cc229b221d4c1d5.tar.bz2
ShemovCleaner-c77061d4d19de23c805ccbcc7cc229b221d4c1d5.zip
Try harder to delete a file
QFile::remove() fails when the read-only attribute is set. Turn out it can be unset with QFile::setPermissions(QFile::ReadOther | QFile::WriteOther). Try it when the initial call to remove() failed.
Diffstat (limited to 'filewidget.cpp')
-rw-r--r--filewidget.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/filewidget.cpp b/filewidget.cpp
index ac7f920..948a5d6 100644
--- a/filewidget.cpp
+++ b/filewidget.cpp
@@ -663,7 +663,11 @@ void FileWidget::deleteFiles(){
QDir d(fi.absoluteFilePath());
d.removeRecursively();
}else{
- QFile::remove(path);
+ if(!QFile::remove(path)){
+ QFile f(path);
+ f.setPermissions(QFile::ReadOther | QFile::WriteOther);
+ f.remove();
+ }
}
removed << idx.data().toString();
}