# Identical files

Source: https://frameleaf.app/docs/admin/physical-deduplication/

In a family, the same photo often ends up on the server more than once: shared holiday pictures, copied phone backups, the same export imported twice. Frameleaf keeps **one file on the drive** for identical files, so exact copies take no extra space. It does this by itself. There's no plan to prepare, no account to choose and nothing to switch on.

This page is the administrator's side: what is merged, when the library is checked, where the extra copies go and what the problems mean. For what each person sees, and for look-alike photos that aren't exact copies, see [Duplicates](https://frameleaf.app/docs/using/duplicates/).

## What happens to identical files

Two files are identical only when every byte matches. Frameleaf reads each whole file from the drive to decide; it never goes by name, date or how a photo looks.

| Where the copies are | What Frameleaf does |
| --- | --- |
| **In two people's libraries** | One file is kept on the drive and both photos use it. Each person keeps their own photo, with its own albums, favourites, descriptions, faces, shared links and Locked state. Libraries stay separate, and each library is still counted at the full size of its photos. |
| **Twice in one person's library** | The two photos become one. Albums, tags, the favourite, the rating and the description carry over to the photo that's kept, and the other goes to the Trash. |

- **The oldest copy is kept.** That's the photo added first.
- **Nothing is deleted from the drive.** The files that are no longer needed move to [Unused files](#unused-files), where they wait until the server's owner empties it.
- **The kept file is checked first.** A copy leaves its place only after the file that stays has been read again and found unchanged.
- **Folders you added from elsewhere stay as they are.** Files in [connected folders](https://frameleaf.app/docs/admin/external-libraries/) are never moved, linked or merged.

Some identical photos are left for a person to decide, because merging them could lose something: photos with edits, a stack, a share of their own, a different Locked state, face corrections, or a merge someone already undid. They appear in the duplicate review marked **Identical file: check before merging**.

## When files are checked

- **As photos arrive.** When an upload or an import brings a file another library already holds, the new photo uses the file that's already there. A file that's already in the same person's library isn't stored again.
- **After a library is imported from another server.** Frameleaf reads every file once to find identical files and anything the old server had lost track of. **Library care** shows the progress under **Checking your imported library**, with **Pause** and **Resume**, and you can keep using Frameleaf while it runs.
- **When you ask.** See below.

### Check the whole library again

1. Open **Settings**, then **Library care**, then **Duplicates**.
2. Under **Identical files are stored once**, choose **Check again**.

The check reads every file again and changes nothing you can see. It runs in the background, carries on after a restart, and waits while a library move is under way. The page says when it last ran, how much space is saved and how many merges it made. The same check can be started as a maintenance job, **Check identical files**; see [Jobs and queues](https://frameleaf.app/docs/admin/jobs/#advanced).

## Undo a merge

Every merge can be undone.

- **In one library:** the person opens **Duplicates** and finds the merge under **Merged for you**, then chooses **Undo**. Both photos are back as they were. See [Duplicates](https://frameleaf.app/docs/using/duplicates/).
- **Across people:** an administrator sees these merges in **Merged for you** too, as "have the same file; each keeps their own". **Undo** moves the person's own file back from Unused files, checks it, and points their photo at it again.

After an undo, Frameleaf doesn't merge those files again by itself. A merge across people can't be undone once Unused files has been emptied, because the person's own copy is gone from the drive; their photo keeps using the shared file.

## Unused files

The copies that are no longer needed wait in **Unused files**, in **Library care** under **Tools**. Only the server's owner, the first administrator account, sees this page and can change it. Other administrators see that extra copies are waiting, but not the list.

- The page says how many files are waiting and how much space they use. The newest are first, and each says whose library it was last in.
- **Restore** puts a file back in the library it was last in.
- **Empty Unused files** deletes the files from the drive for good and gives the space back. The confirmation states the size. No photo uses these files, so every photo in every library stays as it is. This can't be undone.

Space comes back only when Unused files is emptied. A copy that is the last good one of a photo whose file is missing or damaged is kept even then; see [Recover missing or damaged media](https://frameleaf.app/docs/admin/media-recovery/#the-last-good-copy-is-kept).

:::caution[Back up before you empty]
Once identical files share one file, that file matters to everyone who has the photo. Make sure your [backup](https://frameleaf.app/docs/admin/backup-and-restore/) is up to date before you empty Unused files.
:::

## Files found again

While it checks an imported library, Frameleaf also looks in its own folders for files no photo points at.

- A file nobody has comes back as a photo in its owner's library, in an album named **Recovered Media**. The album is marked **Recovered** in Albums.
- A file its owner already has, and a damaged file, go to Unused files instead.
- Files changed in the last hour, uploads still in progress and connected folders are left alone.

## Problems

When a file can't be checked, **Duplicates** lists it under **Problems**. Nothing is merged on a guess: these files are left as they are.

| Problem | What it means |
| --- | --- |
| **Could not be read from the drive** | The file is missing, unreadable or damaged. It's left as it is, and [File checks](https://frameleaf.app/docs/admin/system-integrity/) looks at it that night. |
| **Changed while it was being read** | Something was writing to the file. It's read again in the next check. |
| **Not merged** | The file is in a folder Frameleaf reads but never changes. Files in folders you added from elsewhere stay as they are. |

## Good to know

- The space saved also shows in **Settings**, then **Storage & originals**, as **Identical files are stored once**.
- Phones and the desktop app still recognise a photo they already uploaded, so a merge doesn't make them upload it again.
- The check runs only on your server. It never goes to another computer or to Frameleaf Cloud. See [Workers and where jobs run](https://frameleaf.app/docs/admin/workers/).
- The older reviewed-plan tool, with its account picker and **Apply reviewed plan**, is gone. Its API addresses under `/api/admin/physical-deduplication` answer that they were replaced by `/api/admin/identical-files`.
