Uploads
All uploads, including small files, use one chunked protocol (UploadController, resources/js/uploader.js). There is no separate "simple" path.
The client is an Alpine store, $store.uploads (registered in resources/js/app.js), and the progress panel sits in a @persist('uploads') block in the layout, so uploads carry on while you navigate between pages. Each item remembers its target folder when it is added. A browser page reloads its list on the ferrite-uploaded window event. A full page reload or closed tab still stops an upload (the browser asks first); adding the same file again resumes it.
POST /uploadswithpath(a name, or a relative path such asphotos/2026/a.jpg),size, optionalparent_idandfingerprint. Missing folders in the path are created. Returns the uploadid, the currentoffsetand thechunk_size. Starting the same file again (same parent, name, size, fingerprint) resumes the unfinished upload.PATCH /uploads/{id}with the raw chunk as body and anUpload-Offsetheader. A wrong offset gets409with the real offset, so the client resumes from there. The last chunk finalizes the upload.GET /uploads/{id}returns the state (status:receiving,processing,donewith thenode, orfailedwith anerror);DELETE /uploads/{id}cancels (409 while processing).
Files that already exist. Before a batch is queued, the browser asks POST /uploads/conflicts (paths, optional parent_id; FindUploadConflicts) which of the paths would meet something of the same name, looking inside existing folders for the files of a dropped folder. If anything does, a dialog offers Replace, Keep both, Skip existing and Cancel; a dropped folder that already exists is merged into it, and only same-named files are in question. The choice is sent as replace on POST /uploads. The check is advisory: the real decision is made when the file is stored.
- Keep both (the default, also for the API): the new file becomes
name (2).ext. - Replace:
CompleteUploadswaps the content of the existing file's node (same id, so share links, favorites and activity stay with it), keeps the old content as a version (docs/versions.md; up toFERRITE_VERSIONS_KEEP, default 5, and counted in the quota), or, with versions off or no room in the quota, adjusts the quota by the difference and deletes the old blob unless another file still uses it. Needs edit permission on that file; a folder with the name is never replaced (the upload is kept under a new name). The activity log says "replaced". Quota is checked for what the file grows by, not its full size. - Guests of an upload link never replace anything; the server ignores
replacethere and keeps both.
Chunks are appended to ferrite.tmp_path/{id}. The last chunk only marks the upload processing and queues FinalizeUpload, answering 202 at once. The job (CompleteUpload) hashes the file (SHA-256), sniffs its MIME type from the content (the client's is ignored), writes it to the folder owner's disk (the default unless an admin assigned one) under a random key, and creates the node while the owner's row is locked, so quota and used_bytes stay consistent. A name collision keeps both files (a (2).txt). With a remote disk the copy can take minutes, which is why it is not done inside the request: it would time out at the proxy.
The browser keeps sending the next file while a finished one is stored: the panel shows "Sent. Storing the file…" and polls GET /uploads/{id} (every 1 to 5 s) until done or failed, then deletes the record (the server keeps it until then, or until uploads:prune an hour later). Closing the tab during that phase is harmless; the file still arrives, only a failure message would be missed. With QUEUE_CONNECTION=sync (no worker) the job runs inside the last chunk's request, as before, and that response is 200 with the node (or 422 with status: failed). The chunk lock is released before storing starts; the processing status keeps further chunks out.
Failures. A job that fails (quota gone, disk unreachable, a crash) removes the temporary file and, if it already wrote a blob that no node uses, that blob from the disk (FailUpload; the key is noted on the upload row before writing, so this works after a crash too, and a copy that fails halfway deletes its partial file at once). The upload is marked failed with the reason, the browser shows it with a Retry button, and uploads:prune drops the record an hour later. A job has one try and a six-hour limit (FinalizeUpload). It runs on its own queue connection, uploads, whose retry_after (21700 s) is above that limit so the job is never started twice; other jobs keep Laravel's 90 s. uploads:prune gives up on uploads still processing FERRITE_PROCESSING_TIMEOUT_HOURS (12) after the job started (it died), or a week after they were queued if no worker ever picked them up, and cleans them the same way. The job and FailUpload both check the status under a row lock before acting, so a timeout and a late-finishing job cannot both win: the job either creates the node or deletes what it wrote. If no node was created, there is nothing on the disk afterwards and nothing counted against the quota.
Worker stopped. Checked against a real Hetzner Storage Box disk: stopping the upload worker while a copy is queued or running does not fail the upload. It stays at "Storing the file…" and finishes after the worker is started again. A job whose process is killed outright stays reserved until retry_after (about 6 h) or the daily uploads:prune (FERRITE_PROCESSING_TIMEOUT_HOURS) gives up on it, so the browser can show "storing" for hours in that case.
After a deploy, rebuild the caches and restart the worker, or the page fails with errors such as Route [favorites] not defined or The [uploads] queue connection has not been configured: php artisan migrate --force && php artisan optimize:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache && php artisan queue:restart. The uploads worker must be started as queue:work uploads --queue=uploads --tries=1 --timeout=0 (the connection name is uploads, not database).
Quota is checked when the upload starts and again on completion. It is not reserved in between, so parallel uploads can each pass the first check; the second one fails on completion.
uploads:prune (daily) removes unfinished uploads untouched for ferrite.upload_ttl_hours, fails stuck ones and drops the records of finished ones (see above).
Deduplication
Identical files of the same owner on the same disk (same SHA-256 and size) share one blob: the second upload skips the write and its node points at the existing key. Scope is per owner, so nobody can learn whether someone else stores a file. Quota is still charged per node at full size, so dedup only saves disk space.
There is no reference count to drift: a blob's users are the nodes rows with that disk_id and path (indexed). PurgeNode deletes the rows first, then removes the blob and its thumbnail only if no node still uses it. On upload, the source node is locked (FOR UPDATE) inside the transaction that creates the new node, so a concurrent purge either finishes first (the upload then writes its own copy) or sees the new node. Not done: skipping the upload itself (needs a client-side hash) and merging duplicates that were stored before this change.
Deployment limits
Chunks are FERRITE_CHUNK_SIZE bytes (default 5 MiB). The web server's body limit must be larger than that (nginx client_max_body_size). PHP's upload_max_filesize does not apply, since the body is not a form upload; keep post_max_size above the chunk size as well, as docs/install.md says. The temporary file needs room for the whole file: plan FERRITE_TMP_PATH (the tmp/ folder of the data volume in Docker) for the largest file times the number of uploads in flight, plus the same again on the target disk. A queue worker must run (the Docker image starts one; see docs/install.md).
Tested end to end with a 100 MB file, and with a 3000 MB file to an SFTP server (a local OpenSSH one): see tests/Feature/Remote/SftpDiskTest.php and docs/storage-search-activity.md.
Found a mistake? This page is docs/uploads.md in the repository.