darktable-org / darktable-org/darktable

Can't drop cache more than 1 time for an image

Open
#18,524 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

no-issue-activity
Dominant language
C
Stars
13.1k
Forks
1.4k
Avg merge
22h 14m
Merged PRs (30d)
198

Description

Is there an existing issue for this?
  • I checked and did not find my issue in the already reported ones
Describe the bug

Pursing a Lua solution to the pixls.us discussion https://discuss.pixls.us/t/can-i-force-the-refresh-of-a-file-in-darktable/48555.

My thought was to drop the cache for the image, then regenerate it.

This works the first time, but on second and later attempts the cache is not dropped

Troubleshot it down to

     // due to DT_MIPMAP_BUFFER_DSC_FLAG_INVALIDATE, removes thumbnail from disc
+    fprintf(stderr, "removing from disk\n");
     dt_cache_remove(&_get_cache(cache, mip)->cache, key);
   }
   else
   {
+    fprintf(stderr, "took the else\n");
     // ugly, but avoids alloc'ing thumb if it is not there.
     _mipmap_cache_unlink_ondisk_thumbnail((&_get_cache(cache, mip)->cache)->cleanup_data, imgid, mip);
   }

in src/common/mipmap_cache.c.

The first time I remove it, the code takes the dt_cache_remore() and the second time it takes the else and the cache is not removed.

Steps to reproduce
  1. import a non-raw into darktable
  2. open the image in gimp
  3. start the reload script
  4. make a change to the image in gimp and then select overwrite file to replace the image
  5. select the image in lighttable and click the reload button in actions on selected images module
  6. image cache is updated.
  7. make another change in gimp and overwrite again
  8. click the reload button and notice no update.
Expected behavior

The image cache should have dropped, so it could be recrated witht he updated image.

Logfile | Screenshot | Screencast

No response

Commit

No response

Where did you obtain darktable from?

self compiled

darktable version

current master

What OS are you using?

Linux

What is the version of your OS?

Ubuntu 22.04

Describe your system

gaming laptop i7

Are you using OpenCL GPU in darktable?

Yes

If yes, what is the GPU card and driver?

nvidia 3070ti latest

Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip

Here's the script,

reload.zip

Unzip it, drop the lua file in your lua scripts, then enable it from script_manager. It adds a button to the actions on selected images module to reload the cache for the selected image.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/common/mipmap_cache.c and reproduce the behavior using the attached reload.zip Lua script on an imported non-raw image. Trace the cache-removal path around DT_MIPMAP_BUFFER_DSC_FLAG_INVALIDATE and compare the first and subsequent reloads. Done means overwriting the image and reloading it repeatedly updates the image cache each time.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.