FilesystemChunkUploadSessionStore
final class FilesystemChunkUploadSessionStore (View source)
| internal | ChunkUploadService owns this persistence boundary. |
Persists and serializes temporary chunk sessions below the application's writable path.
It owns session metadata, assembled payload files, and per-session locks without exposing client filenames or profiles as filesystem path components.
Constants
| private QUOTA_LOCK |
|
| private RETIRED_DIRECTORY |
|
| private INITIALIZING_DIRECTORY |
|
Methods
Resolves private storage and retains the quota, path, and atomic-move boundaries used by session mutations.
Returns the private root under which all chunk session directories are stored.
Atomically reserves global capacity and creates metadata without creating a payload file.
Runs a session operation while holding that session's exclusive filesystem lock.
Runs a cleanup operation only when the session lock is immediately available.
Rehydrates persisted metadata, or returns null when the session directory has no metadata file.
Returns the actual assembled payload size, treating a not-yet-created payload as empty.
Returns the internal assembled-payload path for a validated session identifier.
Appends one already validated chunk and publishes the advanced offset only after its full payload size is verified.
Atomically removes a session from the active namespace and then best-effort deletes its retired data.
Lazily yields syntactically valid session identifiers currently present below the chunk root.
Best-effort removes a bounded number of retired or interrupted-initialization directories.
Returns the directory modification timestamp used as a cleanup fallback for unreadable metadata.
Details
__construct
__construct(Filesystem $filesystem, UploadPathPolicy $pathPolicy, ChunkUploadConfig $config, Closure|null $atomicMove = null, Closure|null $afterSessionPublished = null)
Resolves private storage and retains the quota, path, and atomic-move boundaries used by session mutations.
root
string
root()
Returns the private root under which all chunk session directories are stored.
create
void
create(ChunkUploadSession $session)
Atomically reserves global capacity and creates metadata without creating a payload file.
withLock
mixed
withLock(string $uploadId, callable $callback)
Runs a session operation while holding that session's exclusive filesystem lock.
Missing sessions do not create lock files and return null; upload exceptions raised by the callback retain their original category after the filesystem lock boundary.
tryWithLock
mixed
tryWithLock(string $uploadId, callable $callback)
Runs a cleanup operation only when the session lock is immediately available.
A missing, initializing, or currently active session returns null without waiting.
load
ChunkUploadSession|null
load(string $uploadId)
Rehydrates persisted metadata, or returns null when the session directory has no metadata file.
payloadSize
int
payloadSize(string $uploadId)
Returns the actual assembled payload size, treating a not-yet-created payload as empty.
payloadPath
string
payloadPath(string $uploadId)
Returns the internal assembled-payload path for a validated session identifier.
append
ChunkUploadSession
append(ChunkUploadSession $session, string $chunk)
Appends one already validated chunk and publishes the advanced offset only after its full payload size is verified.
A write or metadata failure truncates the payload back to its original size before the error escapes.
remove
void
remove(string $uploadId)
Atomically removes a session from the active namespace and then best-effort deletes its retired data.
Once the same-filesystem rename succeeds, retries cannot observe or complete the session again.
uploadIds
iterable
uploadIds()
Lazily yields syntactically valid session identifiers currently present below the chunk root.
cleanupRetired
int
cleanupRetired()
Best-effort removes a bounded number of retired or interrupted-initialization directories.
sessionModifiedAt
int
sessionModifiedAt(string $uploadId)
Returns the directory modification timestamp used as a cleanup fallback for unreadable metadata.