D19887: KFileItem: call stat() on demand, add SkipMimeTypeDetermination option

David Faure noreply at phabricator.kde.org
Wed Mar 27 08:48:32 GMT 2019


dfaure requested changes to this revision.
dfaure added a comment.
This revision now requires changes to proceed.


  Thanks.
  
  Did you also run the kio unittests to ensure they still pass?

INLINE COMMENTS

> kfileitem.cpp:203
>      // stat() local files if needed
>      // TODO: delay this until requested
>      if (m_fileMode == KFileItem::Unknown || m_permissions == KFileItem::Unknown || m_entry.count() == 0) {

Remove the TODO :-)

> kfileitem.cpp:491
> +    QMimeDatabase db;
> +    if (m_bSkipMimeTypeDetermination) {
> +        const QString scheme = url.scheme();

So, we don't really skip it. We just use a "fast and less precise" mode.

Sounds like this should be called DetermineMimeTypeFromExtension (though that's incorrect for http),
or FastMimeTypeDetermination (but people then think it's a good idea to call this in all cases...)
or SkipMimeTypeFromContent -- maybe better?

> kfileitem.cpp:1019
>  
> -    if (isLocalUrl && !delaySlowOperations && isDir()) {
> +    if (isLocalUrl && !delaySlowOperations && !d->m_bSkipMimeTypeDetermination && isDir()) {
>          if (isDirectoryMounted(url)) {

It reads like a bit of a hack here, because reading .directory is unrelated to mimetype determination.

But I think your idea is that isDir() is what we don't want to call right?
Another way to do this, then, would be to change isDir() to have an early `return false` if mimetype determination is skipped?

> kfileitem.cpp:1605
>          QMimeDatabase db;
> -        if (isDir()) {
> +        if (!d->m_bSkipMimeTypeDetermination && isDir()) {
>              d->m_mimeType = db.mimeTypeForName(QStringLiteral("inode/directory"));

my suggestion would simplify this here too

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D19887

To: hoffmannrobert, dfaure, #frameworks, #dolphin
Cc: kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20190327/648b8538/attachment.htm>


More information about the kfm-devel mailing list