Bug 144553 - JPG and PNG and GIF get corrupted to zero size on export if resaved under the same name
Summary: JPG and PNG and GIF get corrupted to zero size on export if resaved under the...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
6.3.0.4 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected
Depends on:
Blocks: Graphics-Export
  Show dependency treegraph
 
Reported: 2021-09-16 17:50 UTC by Daniel Baran
Modified: 2024-07-18 14:54 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Baran 2021-09-16 17:50:54 UTC
Description:
When I open a JPG and then export as JPG the result is a zero byte file.
This only happens when I overwrite to the original file name.
I have repeated this in several tests with different files.


Steps to Reproduce:
1.Open a JPG file
2.Export as JPG using the original file name
3.Agree to overwrite (per file exists warning)



Actual Results:
Output file is corrupted - byte size is zero


Expected Results:
Overwrite the original file with the modified version



Reproducible: Always


User Profile Reset: No



Additional Info:
Version: 7.1.6.2 (x64) / LibreOffice Community
Build ID: 0e133318fcee89abacd6a7d077e292f1145735c3
CPU threads: 8; OS: Windows 10.0 Build 19043; UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded
Comment 1 Timur 2021-09-17 09:31:00 UTC
In LO 6.2 error dialog "Writer error. File could not be written". 
Repro LO 6.3 and 7.3+ Windows and Linux.

In Linux 6.2 and 6.3 and 6.4 master there's a crash on save, so bibisect should be done in Windows.
Comment 2 Timur 2021-09-17 10:11:40 UTC
May be the same bug: when PNG Options appear, see size, click in Resolution field, see that size becomes 0.
Comment 3 Henrik Palomäki 2021-09-21 07:15:20 UTC
Should the wanted behaviour be similar for example to the GIMP's export tool? It overwrites the file that has a same name. Or is it enough to show an error dialog and leave the file intact?
Comment 4 Daniel Baran 2021-09-21 17:15:20 UTC
I think the current message dialog is proper.
That is: "filename.jpg already exists.  Do you want to replace it?"
But presently, if you reply "yes" to overwrite, you get a zero byte file.
Comment 5 Daniel Baran 2021-10-04 17:45:07 UTC
Assuming there may be good reasons to avoid overwriting the open file,
a good alternative might be changing the message box to something like:
"filename.jpg already exists - choose a new filename."
Comment 6 QA Administrators 2023-10-05 03:19:54 UTC Comment hidden (obsolete)
Comment 7 Daniel Baran 2023-10-05 21:48:07 UTC
Per QA Team request:
Using the version below, I still see the same behavior.
If I export to a new filename, the file is good.
If I export to the same filename the file is zero bytes.
Hope this helps.
 

Version: 7.5.6.2 (X86_64) / LibreOffice Community
Build ID: f654817fb68d6d4600d7d2f6b647e47729f55f15
CPU threads: 12; OS: Windows 10.0 Build 22621; UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded
Comment 8 Daniel Baran 2023-10-05 22:47:25 UTC
Adding:
I'm seeing the same behavior in the following versions as well.
Export to a new filename, the file is good.
Export to the same filename the file is zero bytes.

Version: 7.5.7.1 (X86_64) / LibreOffice Community
Build ID: 47eb0cf7efbacdee9b19ae25d6752381ede23126
CPU threads: 12; OS: Windows 10.0 Build 22621; UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded

Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 12; OS: Windows 10.0 Build 22621; UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded
Comment 9 Stéphane Guillou (stragu) 2024-02-28 12:55:26 UTC
reproduced with recent trunk build:

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: a1a1d8edb9d4a62b747aa7069b3026e2ba75704d
CPU threads: 8; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded
Comment 10 u34 2024-07-13 22:11:37 UTC
Issue reproduced with
Version: 24.2.5.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 2; OS: Linux 6.9; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
24.2.5-1
Calc: threaded

Referring to the Steps to Reproduce from the description (comment#0) 
1.Open a JPG file. Initially, there was no lock file. After the file got opened, the lock file appeared.
2.Export as JPG using the original file name
3.Agree to overwrite (per file exists warning). In my case, after the pop up window to confirm over writing an existing file, I also had a pop up window to set some aspects of the way the image would be saved. After I agreed to the default suggestions, the lock file disappeared, and the file got truncated to 0 (zero) size.
Comment 11 u34 2024-07-13 23:24:48 UTC
Referring to my own comment#10: I used the words aspects how the image would be saved. A better choice of words is aspects how the image would be exported.

Issue reproduced with
Version: 24.2.5.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 2; OS: Linux 6.9; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
24.2.5-1
Calc: threaded

Referring to the Steps to Reproduce from the description (comment#0) 
1.Open a JPG file. Initially, there was no lock file. After the file got opened, the lock file appeared.
2.Export as JPG using the original file name
3.Agree to overwrite (per file exists warning). In my case, after the pop up window to confirm over writing an existing file, I also had a pop up window to set some aspects of the way the image would be exported. After I agreed to the default suggestions, the lock file disappeared, and the file got truncated to 0 (zero) size.
Comment 12 Stéphane Guillou (stragu) 2024-07-18 14:54:32 UTC
Bibisected the commit that made the switch from error message to 0-byte export with linux-64-6.3:

commit 6a58859bf24c949e2531fffe5e999bcc868414c8
author	Caolán McNamara Thu Feb 07 10:29:45 2019 +0000
committer	Caolán McNamara Thu Feb 07 13:28:53 2019 +0100
Resolves: rhbz#1673198 cannot overwrite open file with export
this reverts
commit 3c4cfa209f446fc433c8d3925cbbe628c2f536e8
Date:   Mon Nov 26 12:51:05 2007 +0000
    INTEGRATION: CWS fwk72 (1.195.14); FILE MERGED
    2007/09/10 14:55:01 mav 1.195.14.1: #i81437# do not allow to export to the file the document is based on
Reviewed-on: https://gerrit.libreoffice.org/67491

Not mentioned in the commit message, that fixed bug 103947.

Caolán, what do you think?