Back to BlogEngineering

How FileOctopus checks every copy

How FileOctopus checks a copy before it counts as done: a checksum taken while copying, flush, read-back, and the special rules for SMB shares and NAS servers.

7 min readBy

Line drawing of a document being copied from a Mac to a network drive, with a check mark over the copy.

In short

  • Every copy is checked before it counts as done. A SHA-256 checksum is taken while copying, the copy is flushed to the disk, then compared with the original by checksum, size and metadata.
  • A move, or a copy that replaces an item, is also read back from the disk, past the Mac's memory cache, before anything is removed. A plain copy is not.
  • Network shares get their own rules. FileOctopus measures what a share keeps and leaves out only what it saw the share drop.
  • The cost: checking while copying took an 8 GB copy from 28.26 s to 8.65 s (MacBook Pro with M3 Max, macOS 26.5.1, the change shipped in 1.1.2).

The first post in this series said a move removes the original last. That rule is only as good as the check before it. This post is about that check.

On a NAS it is harder than it sounds, and most of our lessons came from there.

What happens to every copy

  1. Copy under a hidden name, so a half-written file never has the real name.
  2. Take the checksum while copying. Each file is read once, and its SHA-256 checksum is computed from the same bytes as they are written.
  3. Flush. Each file is handed to the disk, then one full flush asks the drive to move its own cache onto stable storage.
  4. Compare the copy with the checksum, the size and the original's metadata. The original must still be what was copied.
  5. Put in place with a rename that refuses to replace anything.
  6. Check at its place, under its real name, before the operation counts as done.

If a step fails, the original is untouched. The progress row shows the steps: Verifying…, Verifying again, Checking the copy.

Which copies are read back

A read-back reads every byte of the copy again from the disk: the strongest check, and the slowest. Since 1.1.2, a plain copy (nothing removed, nothing replaced) is not read back. It is checked by the checksum taken while copying, every read, write and flush result, its size and metadata. Your original stays whatever happens.

A move, and a copy that replaces an item, read the copy back once, right before the original or the replaced item goes. Since 1.1.5, a replaced file goes to the Trash only after the new one is checked, so Undo can put it back. That read skips the Mac's memory cache, which could otherwise answer from bytes it still holds:

if Self.readsBackFromVolume { _ = Darwin.fcntl(descriptor, F_NOCACHE, 1) }

What is compared

Part of the itemHow it is checked
ContentsSHA-256 of every file's bytes
SizeExact
Permissions, owner, flags such as LockedExact, where the disk can store them
Modification and creation datesAt the precision the disk keeps
Extended attributes, access listsExact, where the disk can store them
A folderEvery item inside, with its name and kind

"Where the disk can store them" is the hard part. An exFAT USB stick keeps no Unix permissions and only 2-second times, so a copy there is checked for what it keeps. On a share, it depends on the server.

Why network shares need their own handling

The share can't promise the data is stored

The Mac's SMB client has no full flush. So when you move items onto a share, FileOctopus flushes the copy to the server and reads it back from the server, past the cache, with fresh attributes. Only when that matches do the originals go to your Mac's Trash, where ⌘Z can bring them back.

Names spelled differently

An accented letter such as "é" can be stored as one character or as a letter plus an accent. They look the same but compare differently. On macOS 27, a share can list a just-copied name in the other form and answer "not found" for the form FileOctopus wrote. FileOctopus now finds the copy by the spelling its folder lists, and checks it as before.

Dates the server changes

Each was measured first:

  • A share on a FAT or exFAT drive keeps 2-second steps. Both sides are rounded the way that share rounds.
  • A server on a disk with whole seconds rounds 12.7 s to 13 s. Both sides are rounded to the nearest second.
  • Some NAS servers set the date again when a file is closed. FileOctopus sets the dates after closing and checks again. If the share still won't keep a date, the copy says so and a move keeps the original.

Attributes a share can't keep

Nothing is guessed from the kind of disk. Once per share, inside its own staging folder and never in a folder of yours, FileOctopus writes a one-byte probe file, sets a creation date, permissions and some flags on it, and reads each back from the server. Only what the share was seen to drop is left out of the comparison. Anything it couldn't measure stays strict.

A NAS without Apple's SMB extensions, for example, reports the same permissions for every file, so there permissions are left out while contents, size and dates still count. Where a share can't keep a custom icon or tags, you're told what it didn't keep.

Servers that give a file a new ID on rename

Normally the final rename is proven by the file's ID. Some servers, such as Samba with file IDs turned off, give a file a new ID on every rename. There, FileOctopus binds the rename by the item's size, dates and permissions, then checks the copy at its place by its full contents.

Originals moved off such a share are removed only after the copy is checked, and only if still exactly what was copied. Anything that changed is kept.

What the checks cost

Until 1.1.2, FileOctopus read every file before copying it, then a plain copy's checks read original and copy three times each. A 90 GB copy spent minutes on "Checking…". In 1.1.2 the checksum moved into the copy itself.

Plain copyBefore the changeWith the 1.1.2 change
8 GB, first byte written6.96 s0.02 s
8 GB, total28.26 s8.65 s
Extra reads by the checks (original, copy)3, 30, 0

How far these numbers go. One Mac, one destination, and the report doesn't say the timing was repeated. A move pays for its read-back: in a 10 GB move on a Mac mini with M4 (macOS 27.0, FileOctopus 1.1.3), it took 13.7 s of 42.1 s. Until 1.1.6, a move onto a share read its copy twice, on the Mac and from the server: a 10 GB move onto a Samba test share from that Mac mini read 20 GB of the copy (1.1.3). Since 1.1.6 it reads it once: in our test, a 2 GB file moved to an SMB share took 6.5 s instead of 10.3 s (MacBook Pro with M3 Max, macOS 26, one run on the change's development branch). Share timings vary with load, so treat these as examples, not promises.

Where we got it wrong

From our release notes:

Fixed inWhat was wrong
1.0.5Copy, move and rename failed on SMB shares. Moves onto a share now read the copy back from the server before the originals go to the Trash.
1.0.9Copies from camera cards and other FAT32 or exFAT disks to a NAS failed the check.
1.1.1Permissions a NAS without Apple's SMB extensions can't store made copies fail.
1.1.2Copies spent a long time checking. Folders with accented names failed the check on SMB shares, including on macOS 27.
1.1.3Copies and moves to NAS shares failed over dates the server changes, hidden flags or custom icons it can't keep, read-only files, or a share on an exFAT drive.
1.1.5Copying a file dated before 1980 onto an exFAT or FAT disk failed.
1.1.6Big moves to a network share read the copy two or three times before removing the original. Now they read it once.

In each case the original was kept; the cost was a failed or slow copy. Two worse ones were caught before release. A test showed a move's read-back ran too early to see a server losing the write after the final rename; it now runs at the final place. A safety review found that a move could remove an original rewritten after the copy with its size and date put back; the original is now checked again before it goes.

What isn't covered

  • A plain copy is not read back, so a drive that accepts data and then loses it wouldn't be caught. Your original is still there.
  • A copy between drives cut off by a power loss isn't verified in every setup yet.
  • Proving a move's original unchanged without reading it again works only on your Mac's APFS disks in macOS 27. Elsewhere the original is read again.
  • On shares that give a file a new ID on rename, Replace, merging folders and renaming several items at once are refused, because the result can't be checked. Originals moved off such a share don't go to a Trash.

The full list is on the current limits page, and the file operations guide describes each step and share note. FileOctopus is not a backup; these checks make sure a copy is a copy.