Bug 433127 - Dolphin thumbnail confusions
Summary: Dolphin thumbnail confusions
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 20.12.2
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-17 23:08 UTC by tagwerk19
Modified: 2021-03-01 11:47 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.80
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tagwerk19 2021-02-17 23:08:50 UTC
SUMMARY:

    If image files are renamed, in the case of swapping names of
    two files, dolphin loses track of the thumbnails... 

STEPS TO REPRODUCE:

    Create two images, "one.jpg" and "two.jpg", under Pictures. Open the
    folder in Dolphin

    Rename "two.jpg" to "twox.jpg". The file is renamed and the
    thumbnail remains "as it should be"

    Rename "one.jpg" to "two.jpg"... 

OBSERVED RESULTS

    The file is renamed but the thumbnail changes to that of the
    "earlier" two.jpg. That is, both files appear with the same thumbnail

EXPECTED RESULTS

    The thumbnail remains "as it was" 

ADDITIONAL INFORMATION

    Was reported in a comment under Bug 432890, probably needs to
    stand on its own.

    One never knows, maybe some connection to bug 433116 

SYSTEM INFORMATION

    Neon Testing
    Dolphin : 20.12.2
    Plasma : 5.21.0
    Frameworks : 5.79.0
    Qt : 5.15.2
Comment 1 Méven Car 2021-02-18 06:05:05 UTC
Files names are what it used as keys in the thumbnail cache.


If we want to solve this either we use other kind of keys like a hash of inode id / device id combination or we implement a special case in dolphin when renaming files, but that is tricky, or we implement some cache invalidation when files are moved / deleted.
Comment 2 tagwerk19 2021-02-18 08:02:56 UTC
(In reply to Méven Car from comment #1)
> Files names are what it used as keys in the thumbnail cache.
Ouch...

> ... like a hash of inode id / device id combination ...
Maybe the source node id can be held in a thumbnail xattr (and, if present, used for cross checking)

> ... or we implement some cache invalidation when files are moved / deleted.
Or maybe "when it is noticed".

It would definitely be nice if refreshing the panel sorted the thumbnails.
Comment 3 Nate Graham 2021-02-18 15:19:18 UTC
Isn't this stuff governed by a FreeDesktop.org spec? If there's an issue with the thumbnail keys, it might need to be fixed in the spec first.
Comment 4 tagwerk19 2021-02-18 17:16:12 UTC
https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html

Which talks about attributes in the PNG file: a couple being required:

    Thumb::URI
    Thumb::MTime

plus some additional, including

    Thumb::Size

If I poke around in my thumbnail PNG's, I see that these are being used. They would be enough to catch the issue I was having. The spec also leaves open the option of further 'X-' prefixed attributes.
Comment 5 tagwerk19 2021-02-18 18:11:37 UTC
There's a section covering detecting modifications:

https://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html#MODIFICATIONS

If I delete all the thumbnail PNGs, touch one of the source images and rerun the test, the thumbnails work as they should.

If dolphin is checking the filename and modification time, that's not enough for my case. It also proved not enough for the test scenario (which is of course simplified!). Add in a check of the file size, and it would have been OK.
Comment 6 tagwerk19 2021-02-19 16:49:32 UTC
Posted a suggestion:

    https://gitlab.freedesktop.org/xdg/xdg-specs/-/issues/72

to suggest comparing the file size (in the cases it exists in the PNG metadata) as well as the modification time.
Comment 7 Bug Janitor Service 2021-02-20 08:11:20 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/350
Comment 8 Méven Car 2021-02-20 08:17:58 UTC
This (In reply to tagwerk19 from comment #6)
> Posted a suggestion:
> 
>     https://gitlab.freedesktop.org/xdg/xdg-specs/-/issues/72
> 
> to suggest comparing the file size (in the cases it exists in the PNG
> metadata) as well as the modification time.

I would encourage you to fill a MR yourself, no coding involved, you can do it from the browser. https://gitlab.freedesktop.org/xdg/xdg-specs/-/blob/master/thumbnail/thumbnail-spec.sgml

In any case KIO does support time modification check but with a *second* precision meaning this bug can only happen when the two files share the same modification time modulo one second.

This will add file size to the cache validation check
https://invent.kde.org/frameworks/kio/-/merge_requests/350
Comment 9 David Faure 2021-02-20 11:40:23 UTC
Git commit b33307901f30ec8d724a7e424838165746563d06 by David Faure, on behalf of Méven Car.
Committed on 20/02/2021 at 11:40.
Pushed by dfaure into branch 'master'.

PreviewJob: consider file size for cache invalidation

M  +2    -1    src/widgets/previewjob.cpp

https://invent.kde.org/frameworks/kio/commit/b33307901f30ec8d724a7e424838165746563d06
Comment 10 tagwerk19 2021-02-22 07:46:12 UTC
(In reply to Méven Car from comment #8)

> ... I would encourage you to fill a MR yourself, no coding involved ...
Every day a learning day, how about

    https://gitlab.freedesktop.org/xdg/xdg-specs/-/merge_requests/42
Comment 11 tagwerk19 2021-03-01 11:47:41 UTC
Yes, able to swap two files (that have the same timestamp) filenames.

That works, many thanks!

With
    Neon Testing
    Plasma : 5.21.1
    Frameworks : 5.80.0
    Qt : 5.15.2