Re: Repair corrupted odt

2014-11-26 Thread Robinson Tryon
On Sun, Nov 23, 2014 at 6:01 AM, Olivier Chorier  wrote:
> Hello everybody,
>
> I'm looking for a way to repair thousands of corrupted odt files. Those
> files have been corrupted after FTP send operations, for some reason.
>
> The "zip" structure seems corrupted. I tried using 7-zip to unzip and zip
> again the odt file, but it doesn't work every time.
> Libre Office can repair them every time, but I need to open, repair, save
> and close those files one by one.

Any chance you could share some of the mildly-corrupted files
publicly? If LibreOffice is doing a good job of repairing your
corrupted files, perhaps we could add a few to our automated tests to
ensure that the codebase continues to be able to recover from your
particular type of file damage.

> I wonder if a script or something like that could be used to repair those
> files. I can't do it manually because there is thousand of them. Ideally, I
> could check them, and repair them automatically using a bash or a java
> script...

Others know much more than I about how LibreOffice repairs files, but
to verify that the files are fixed, there are some good packages for
validating ODF, including the office-o-tron, which can be run on the
command line:
https://wiki.documentfoundation.org/ODF#Validator_Software

Cheers,
--R

-- 
Robinson Tryon
QA Engineer - The Document Foundation
LibreOffice Community Outreach Herald
qu...@libreoffice.org
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Repair corrupted odt

2014-11-26 Thread Marco Lechner - FOSSGIS e.V.
Hi,

if you are on LInux you could try "unoconv"

Marco

Am 23.11.2014 um 12:01 schrieb Olivier Chorier:
> Hello everybody,
>
> I'm looking for a way to repair thousands of corrupted odt files.
> Those files have been corrupted after FTP send operations, for some
> reason.
>
> The "zip" structure seems corrupted. I tried using 7-zip to unzip and
> zip again the odt file, but it doesn't work every time.
> Libre Office can repair them every time, but I need to open, repair,
> save and close those files one by one.
>
> I wonder if a script or something like that could be used to repair
> those files. I can't do it manually because there is thousand of them.
> Ideally, I could check them, and repair them automatically using a
> bash or a java script...
>
> Thank you very much for your help,
> Olivier.
>
>
> ___
> LibreOffice mailing list
> LibreOffice@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice


-- 
+
FOSSGIS-Konferenz 2015

Selbst beitragen? Call for Papers is out!
FOSSGIS 2015, Die Konferenz für Open Source GIS mit OpenData und OpenStreetMap!
Beiträge einreichen: http://www.fossgis.de/konferenz/2015/callforpapers
+
FOSSGIS e.V.

die unabhängige Hilfe bei freier GIS-Software und freien Geodaten
http://www.fossgis.de
+

Hinweis zu Anhängen die auf .p7m oder .asc enden:
Die .p7m- und .asc-Dateien sind ungefährliche Signaturdateien (digitale 
Unterschriften).
In E-Mail-Clients mit S/MIME Konfiguration (.p7m) oder PGP-Erweiterung (.asc) 
dienen sie zur:
- Überprüfung des Absenders
- Überprüfung einer ev. Veränderung des Inhalts während der Übermittlung über 
das Internet
Die Signaturdateien können ebenso dazu verwendet werden dem Absender dieser 
Signatur eine E-Mail mit verschlüsseltem Inhalt zu senden.

In E-Mail-Clients ohne S/MIME Konfiguration oder PGP-Erweiterung erscheinen die 
Dateien als Anhang und können ignoriert werden.



0x6A30F373.asc
Description: application/pgp-keys
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Repair corrupted odt

2014-11-24 Thread Maxim Monastirsky
On Monday 24 November 2014 12:00:45 Piet van Oostrum wrote:
> Well, the zip man page says about the -F and -FF flags:
> 
>   Neither option will recover archives that have been
> incorrectly  transferred in  ascii  mode  instead of binary.
Right, it can't recover already damaged files from the ZIP, but it can extract 
other non damaged files to a new correct zip. And keep in mind that Olivier was 
successful in repairing the files with 7zip and with LO, and I doubt 7zip is 
doing something that zip is not able to do. (And BTW - who said that ASCII 
mode was indeed the cause of the corruption in this case?)

Maxim
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Repair corrupted odt

2014-11-24 Thread Piet van Oostrum
Maxim Monastirsky wrote:

 > The zip utility (of Info-ZIP) has the -F and -FF flags that should be able 
 > to 
 > recover your files. 

Well, the zip man page says about the -F and -FF flags:

  Neither option will recover archives that have been incorrectly  
transferred
  in  ascii  mode  instead of binary. 

-- 
Piet van Oostrum 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Repair corrupted odt

2014-11-24 Thread Maxim Monastirsky
On Sunday 23 November 2014 12:01:32 Olivier Chorier wrote:
> Hello everybody,
Hi Olivier,

> I'm looking for a way to repair thousands of corrupted odt files. Those
> files have been corrupted after FTP send operations, for some reason.
> 
> The "zip" structure seems corrupted. I tried using 7-zip to unzip and zip
> again the odt file, but it doesn't work every time.
> Libre Office can repair them every time, but I need to open, repair, save
> and close those files one by one.
> 
> I wonder if a script or something like that could be used to repair those
> files. I can't do it manually because there is thousand of them. Ideally, I
> could check them, and repair them automatically using a bash or a java
> script...
The zip utility (of Info-ZIP) has the -F and -FF flags that should be able to 
recover your files. Anyway, if you want to use LibreOffice for that, you could 
use the attached Java code as a starting point. The key point in this code is 
to explicitly set the input filter name, and the "RepairPackage" property to 
true in the input MediaDescriptor.

Maximimport com.sun.star.beans.PropertyValue;
import com.sun.star.comp.helper.Bootstrap;
import com.sun.star.frame.*;
import com.sun.star.lang.*;
import com.sun.star.uno.*;
import com.sun.star.util.XCloseable;

public class DocRepair {

public static void main(String[] args) {
try {
XComponentContext xContext = Bootstrap.bootstrap();
XMultiComponentFactory xMCF = xContext.getServiceManager();
Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);

// Open the corrupted document
PropertyValue inputMediaDesc[] = new PropertyValue[3];

inputMediaDesc[0] = new PropertyValue();
inputMediaDesc[0].Name = "Hidden";
inputMediaDesc[0].Value = Boolean.TRUE;

inputMediaDesc[1] = new PropertyValue();
inputMediaDesc[1].Name = "RepairPackage";
inputMediaDesc[1].Value = Boolean.TRUE;

inputMediaDesc[2] = new PropertyValue();
inputMediaDesc[2].Name = "FilterName";
inputMediaDesc[2].Value = "writer8";

XComponentLoader xCLoader = UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);
XComponent xDocument = xCLoader.loadComponentFromURL("file:///home/maxim/Downloads/corrupted.odt", "_blank", 0, inputMediaDesc);

// Save to a new file
PropertyValue outputMediaDesc[] = new PropertyValue[2];

outputMediaDesc[0] = new PropertyValue();
outputMediaDesc[0].Name = "Overwrite";
outputMediaDesc[0].Value = Boolean.TRUE;

outputMediaDesc[1] = new PropertyValue();
outputMediaDesc[1].Name = "FilterName";
outputMediaDesc[1].Value = "writer8";

XStorable xStorable = UnoRuntime.queryInterface(XStorable.class, xDocument);
xStorable.storeAsURL("file:///home/maxim/Downloads/repaired.odt", outputMediaDesc);

// Close the document
XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, xStorable);
if (xCloseable != null) {
xCloseable.close(false);
} else {
XComponent xComp = UnoRuntime.queryInterface(XComponent.class, xStorable);
xComp.dispose();
}
System.exit(0);
} catch (java.lang.Exception e) {
e.printStackTrace(System.err);
System.exit(1);
}
}
}
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Repair corrupted odt

2014-11-23 Thread Terrence Enger
On Sun, 2014-11-23 at 12:01 +0100, Olivier Chorier wrote:
> Hello everybody,

Olivier,

I am afraid that this list is unlikely to give you the help you need.
I shall write my thoughts about your problem, but if you still have
difficulty, the forum at  is a better
place for questions like yours.

It is important to tell us the systems involved, both the source and
the destination of the ftp transfer.  If one of your systems is OS/X,
my comments below apply in priciple, although the detailed form of the
damage is different.

> 
> I'm looking for a way to repair thousands of corrupted odt files. Those
> files have been corrupted after FTP send operations, for some reason.

I would give long odds that you did the ftp transfer in ASCII mode;
this is the default, and it is really easy to forget to change the
transfer mode to BINARY.  The fact that transfers between Unix-derived
systems do not require the specification lets us get into the habit of
forgetting.

> 
> The "zip" structure seems corrupted. I tried using 7-zip to unzip and zip
> again the odt file, but it doesn't work every time.

An ASCII-mode ftp transfer between a Windows-like system and a
Unix-like system converts line endings to match the conventions of the
respective systems.  A "zip" file does not actually consist of lines,
of course.  That is why we call the result "damage".

> Libre Office can repair them every time, but I need to open, repair, save
> and close those files one by one.

I am surprised that LibreOffice can do the repair.  I would have
guessed otherwise.  How sure are you that the result is correct?

If you are forced to recover files this way, let's think of
command-line foo to reduce the number of times you have to pay
attention to the process.

> 
> I wonder if a script or something like that could be used to repair those
> files. I can't do it manually because there is thousand of them. Ideally, I
> could check them, and repair them automatically using a bash or a java
> script...

The most direct and most reliable way is to repeat the ftp transfer,
but precede the actual transfer with ftp command `binary`.  If this
solution is available to you, it is the best by a wide margin IMHO.

You might be able to recover by transferring the files back to the
original system in ASCII mode and then transferring them back to your
current system in BINARY mode.  The emphasis here is on "might": the
translation of line-endings may not be reversible.

HTH,
Terry.

> 
> Thank you very much for your help,
> Olivier.


___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Repair corrupted odt

2014-11-23 Thread Olivier Chorier
Hello everybody,

I'm looking for a way to repair thousands of corrupted odt files. Those
files have been corrupted after FTP send operations, for some reason.

The "zip" structure seems corrupted. I tried using 7-zip to unzip and zip
again the odt file, but it doesn't work every time.
Libre Office can repair them every time, but I need to open, repair, save
and close those files one by one.

I wonder if a script or something like that could be used to repair those
files. I can't do it manually because there is thousand of them. Ideally, I
could check them, and repair them automatically using a bash or a java
script...

Thank you very much for your help,
Olivier.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice