QFile permission not reporting correctly
-
@JonB Yeah, if I changed via command line and Qt didn't see the change then I would suspect a cache. But if writing permissions from Qt I would expect it to update any Qt cache. I would have guess bug, but both QFile and QFileInfo suffering from the same bug makes me think I'm doing something wrong
@ocgltd , @sierdzio
I checked this on my Ubuntu 20.04, Qt5.15, and it does indeed behave as you say. So then I looked and found bug QFile::permissions() returns old, cached value after call to QFile::setPermissions() on the same QFile object, Qt 4.6, Unresolved:I can understand why QFile would not detect changes to the file's permissions outside of the QFile object, although if the permissions
change is done via QFile::setPermissions() then the object can clear its cached value automatically.
Alternatively, the fact that permissions() returns a cached value should be documented.A related issue is that there is no explicit refresh() method for QFile as there is for QFileInfo, although QFile::exists() does trigger a refresh when called
This task is old and has been idle for a long time. It is therefore being closed on the assumption that it will not be addressed in the foreseeable future. If you really do care about this task, you may reopen it and vote for it.
It was created in 2010 and last updated in 2016. We agree it's a bit bad. You will have to use some alternative, e.g. maybe the
static QFilepermissions methods work, or theQFileInfoones. -
Oh my, this should have been fixed, not closed :o
-
-
Thanks! Voted.
-
There is also already a patch for it... sometimes it's interesting to see how long bugs linger around and then a small change (here: chooinsg the correct maintainer) suddenly fixes it :)
-
I guess you can just use the static function!?
-
I guess you can just use the static function!?
-
@HoMa
I suggested earlier that the OP could try that, but there is no guarantee it will behave any differently. The cache may be by filepath, not byQFile/QFileInfoinstance, we don't know. -
@HoMa Not a problem :) I'm just saying it may or may not make any difference! But worth a try.
-
@JonB I'll use the workaround thanks. I couldn't imagine I found such a bug..so I assumed it must be my code.