File Recovery#

JLS is designed to survive the most common failures. When the writer crashes, the computer loses power, or the recording is otherwise not closed correctly, the file is left truncated. The next time you open it, JLS repairs the truncated tail automatically and quickly, regardless of file size. You do not need to do anything for this case.

Some damage is not automatically recoverable. Examples include bit errors or zeroed regions inside the file, often caused by failing storage, interrupted copies, or sync tools. For these files, opening fails, typically with MESSAGE_INTEGRITY. The Joulescope UI may refuse to open the file or fail partway through the data.

JLS provides two tools for these cases:

Tool

Modifies source

Output

Use when

copy

No

New JLS file

Recommended. Also for read-only media.

repair

Yes, in place

Same file

You have a backup and lack space for a copy.

Both tools are available in Python (pyjls) and as the C-based jls command line tool.

Before you start#

  • Make a backup. Copy the damaged file somewhere safe before trying any recovery. Opening a truncated file and repair both write to the file.

  • Check free space. copy writes a new file about the same size as the source.

Repair in place#

repair fixes the damaged file itself, without writing a second copy. It scans the entire file once, relinks around damaged chunks, rebuilds lost index information, and finalizes the file. Where the damaged sample data is still covered by summary (reduction) data, reads over that region return values reconstructed from the summary.

Repair only rebuilds sample (FSR) data. If annotation or UTC time data is damaged, reads of that data may still fail after a successful repair. In that case, use copy on the repaired file or on your backup.

Python#

python -m pip install -U pyjls
python -m pyjls repair damaged.jls

C command line tool#

jls repair damaged.jls

What to expect#

On success, repair prints a summary such as:

repair: 1 dead spans, 1 relinks, 0 clamps, 0 heads rebuilt, 1 entries omitted

Programmatic use#

Applications can offer recovery to their users. Opening a damaged file fails with JLS_ERROR_MESSAGE_INTEGRITY (C) or RuntimeError with MESSAGE_INTEGRITY in the message (Python). Opening a truncated file on read-only media fails with JLS_ERROR_TRUNCATED. In either case, call copy or repair:

Operation

C API

Python API

Copy

jls_copy()

pyjls.copy()

Repair

jls_repair()

pyjls.repair()

Both accept optional message and progress callbacks, and both support cancellation from either callback. See the C API and the Python API for details.

Getting help#

If neither tool recovers your data, please post on the Joulescope forum. Include the tool output and, if possible, a link to the damaged file.