Bug 469450 - digiKam writes metadata to read-only files
Summary: digiKam writes metadata to read-only files
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Engine (show other bugs)
Version: 7.10.0
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-07 13:27 UTC by iwrbko
Modified: 2023-05-07 17:35 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description iwrbko 2023-05-07 13:27:26 UTC
SUMMARY
If a photo is read-only (e.g. -r--r--r--) but in a writable directory and digiKam attempts to write metadata to it, it will succeed (apparently by removing the file first). If I set "Write to XMP sidecar for read-only item only", it will acknowledge the photo is read-only by creating the sidecar, but it will still overwrite the original. If I make the directory read-only, the photo is protected, but digiKam cannot create sidecars. It can, however, modify them, once they exist.

STEPS TO REPRODUCE
1. Create a read-only photo in a writable directory
2. Make sure Metadata>Sidecars>Write to sidecar files is enabled
3. Make sure Metadata>Sidecars>Write to XMP sidecar for read-only item only is selected
4. Make sure Metadata>Rotation>Rotate by changing the content if possible is selected
5. Make sure Metadata>Rotation>Write flag to metadata if possible is enabled (I assume this is necessary to achieve the expected result, but it is not necessary to reproduce the observed result)
6. Rotate the photo

OBSERVED RESULT
The photo is rotated by replacing the read-only file with a modified one and an XMP sidecar is created

EXPECTED RESULT
The photo is rotated by setting a flag in the metadata, which is written to an XMP sidecar

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9

ADDITIONAL INFORMATION
As a workaround, I've made digiKam create sidecars for the photos I'm protecting, restored those photos from a backup, then made those photos and their parent directories read-only. I can now manage metadata in the sidecar without modifying the photo.
Comment 1 caulier.gilles 2023-05-07 13:35:34 UTC
Hi,

Your are right. The image is duplicated with Exiv2 shared library in charge of low level metadata file management. A temp file is created and if metadata are patched fine, original is removed. Normally the files access properties must be restored with the new file.

Gilles Caulier
Comment 2 Maik Qualmann 2023-05-07 17:10:13 UTC
I can't reproduce the problem here with digiKam-8.1.0. The image is not changed when rotating (MD5 checksum checked) and the read flags are not changed. The image rotates in the digiKam view because the orientation flag is written correctly to sidecar and DB. There were some changes here for digiKam-8.0.0.

Maik
Comment 3 Maik Qualmann 2023-05-07 17:15:43 UTC
Ok, I was wrong, used an image with broken JPG data.

Maik
Comment 4 Maik Qualmann 2023-05-07 17:35:41 UTC
Git commit 232218b65221ce49b20a921adad0bed67644a745 by Maik Qualmann.
Committed on 07/05/2023 at 17:34.
Pushed by mqualmann into branch 'master'.

fix rotation of read only files
FIXED-IN: 8.1.0

M  +1    -1    NEWS
M  +2    -1    core/libs/fileactionmanager/fileworkeriface.cpp

https://invent.kde.org/graphics/digikam/commit/232218b65221ce49b20a921adad0bed67644a745