Back to the Media Job Compiler journey

DecidedStop 2 of 13

Recovering a media import that stopped before it finished

Media Intake Service saves its receipt last, so a stopped import can leave real assets behind. A retry rebuilds the lists it uses to find assets from their records. Those assets keep their IDs instead of becoming duplicates.

What can go wrong

Media Intake Service imports media files for a product. Each file becomes an asset with its own ID. One import takes several writes. The service copies the files and writes an asset record for each one, which describes it. It also updates its indexes, the lists it uses to find assets. Last of all it saves a receipt, the saved result of the finished request.

If the import stops partway, a real asset and its record can sit on disk with no receipt. So a missing receipt does not mean nothing happened. The next try has to spot what survived, without giving the same content a second ID.

What I chose

A finished import is the simple case. Each request carries a Media Job Compiler · Media Intake Service · The intake serviceRequest identityTurns the whole request into one fingerprint, used as its ID. It covers the product, the source type and the rights reference. It also covers the file paths and contents.See it in the Media Job Compiler build, which the sender includes again when it retries. The key points to the receipt and to a fingerprint of the request. A fingerprint is a short code that changes when the content changes. The same request gets the first result back. Different inputs under the same key are refused. The service repeats the lookup once it holds the lock for the product. It does this because another sender may have finished the request while this one waited.

With no receipt, the service rebuilds the indexes from the asset records on disk. The indexes find assets by ID, by content fingerprint and by original filename. Only then does the service look for duplicates, so content that was already imported keeps its ID. New content is copied to a Media Job Compiler · Media Intake Service · The intake serviceSafe copyingCopies to a temporary file and makes sure it is fully written to disk. Then it compares the fingerprint and swaps the file into place in one step.See it in the Media Job Compiler build first. Its fingerprint is compared with the one from the Media Job Compiler · Media Intake Service · The intake serviceScan firstShows the accepted files, duplicates and filename clashes before anything is changed.See it in the Media Job Compiler build, the first pass that reads the files. Only a matching copy is moved into place.

How it’s tested

The recovery test removes a receipt, clears the indexes and then retries. It expects the indexes to come back and no second asset record to be made. Other tests cover filename clashes and changed inputs under a used key. Recovery has one limit. It finishes work that was already saved, but it does not undo a whole import.