Bug 419109 - Preserve extended attributes when saving a file
Summary: Preserve extended attributes when saving a file
Status: REPORTED
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: 1.9.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-22 13:28 UTC by Manu
Modified: 2022-11-30 08:50 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manu 2020-03-22 13:28:03 UTC
SUMMARY

It would be nice for Okular to save extended attributes (tags you add using Dolphin, e.g.) when you save a pdf after adding some annotations. Right now, they are lost.


STEPS TO REPRODUCE
1. Add a (baloo) tag to some pdf using, e.g., Dolphin
2. Open the pdf, and add some annotations
3. Save the pdf

OBSERVED RESULT

When you open the pdf again, extended attributes/tags are missing.

Tags


EXPECTED RESULT

Extended attributes should be there just like before saving the pdf.


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Gentoo
(available in About System)
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.67
Qt Version: 5.14.1

ADDITIONAL INFORMATION
Comment 1 Albert Astals Cid 2020-04-08 20:24:23 UTC
Question (adding some baloo devs, Manu feel free to answer too): Does that make sense for Save As too or only for Save?
Comment 2 Stefan Brüns 2020-04-09 08:42:08 UTC
For "Save", I would definitely vote for "preserve as much as possible".

For "Save as ...", I am not sure. There are pros and cons for both possibilities.

Cons:
- It may lead to information leakage. Tags, comments, origin-url ...
- Attributes may no longer apply

Pros:
- It still is mostly the same file
- Manual transfer of attributes is time consuming


Baloo itself does not care either way. As the file is created as a copy (and the old one deleted), it is just a new file which happens to have the same path.
Comment 3 Manu 2020-04-09 08:54:17 UTC
mmmm...that's a good question. I would also do it for "Save as...". When I do "Save us" I expect I'll get a "exact" copy. Anyway, my use case is only for "Save", so I'm fine either way :)

Thanks for looking at this, by the way!!
Comment 4 Nate Graham 2020-04-09 16:08:10 UTC
Good question indeed. Definitely a yes for the save case. For Save As I am leaning slightly towards preserving as well.
Comment 5 tagwerk19 2020-04-14 21:43:56 UTC
What would happen if this information was part of the file (rather than in the extended attributes)? It would be copied/saved as part of the file and managed within the app...
Comment 6 Manu 2020-04-16 12:46:14 UTC
maybe out of my depth here, but I think that goes against the baloo philosophy: if you do that, then *every* program handling the file must know about those attributes (acrobat reader, e.g., would probably crash); extended attributes are handled by the file system and you don't have that problem
Comment 7 Stefan Brüns 2020-04-16 13:25:38 UTC
(In reply to tagwerk19 from comment #5)
> What would happen if this information was part of the file (rather than in
> the extended attributes)? It would be copied/saved as part of the file and
> managed within the app...

There is no "if ..." here.

Any metadata part of the file is in the scope of the application. Applications may or may not preserve any metadata (and sometimes it is not possible to preserve metadata, i.e. when you convert files to a different format without (structured) metadata).
Comment 8 Stefan Brüns 2020-04-16 13:29:14 UTC
(In reply to Manu from comment #6)
> maybe out of my depth here, but I think that goes against the baloo
> philosophy: if you do that, then *every* program handling the file must know
> about those attributes (acrobat reader, e.g., would probably crash);
> extended attributes are handled by the file system and you don't have that
> problem

How is this related to baloo? Baloo just takes any metadata there is, and does not care if it is stored inside the file or in extended attributes.
Comment 9 tagwerk19 2020-04-16 14:32:56 UTC
(In reply to Stefan Brüns from comment #7)
 
> There is no "if ..." here.

The naive view is applications ought to read, copy, save info in the extended attributes _as_if_ it was embedded in the file. It's a least surprise thing.

If it's not possible (because of the filesystem say), they ought to give a warning...
Comment 10 Manu 2020-04-16 14:44:19 UTC
(In reply to Stefan Brüns from comment #8)
> (In reply to Manu from comment #6)
> > maybe out of my depth here, but I think that goes against the baloo
> > philosophy: if you do that, then *every* program handling the file must know
> > about those attributes (acrobat reader, e.g., would probably crash);
> > extended attributes are handled by the file system and you don't have that
> > problem
> 
> How is this related to baloo? Baloo just takes any metadata there is, and
> does not care if it is stored inside the file or in extended attributes.

I was thinking about special Baloo stuff (such as tags and comments) which do not depend on the particular file type (I didn't mean e.g., the bit rate in an mp3 file or the width and height of an image). I think Baloo (since a few years ago, anyway) stores/extracts metadata of the first kind into/from extended attributes. But I don't know that much about this...so maybe I'm wrong
Comment 11 Manu 2022-11-30 08:50:17 UTC
Any update on this? I still find this kind of annoying. I understand the "Save as" scenario is a moot point (I would still go for "also keep them"), but I think just saving should keep them (that's what, e.g., Kate does).