Class FileRecord
java.lang.Object
com.iizix.server.upload.FileRecord
The on-disk record of one file of an upload reservation,
<fid>.json beside <fid>.part. The hwm field is the authority on how many bytes of the part are valid: the part is appended first and the record rewritten after, so on recovery a part longer than hwm is truncated to it, never the other way round.The secret itself is never on disk; only its SHA-256 is, so that a record can be matched to a registry entry without the secret being recoverable from the staging directory.
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionintChunks acknowledged, i.e.final StringThe compression:gzipornone.final intThe file index inside the reservation.final StringThe group name, empty for none.longCompressed bytes acknowledged: the valid length of the part.longThe last write time in milliseconds.longThe uncompressed size measured at verification, -1 until then.final longThe client's last-modified time in milliseconds, 0 if unknown.final StringThe client's original name, verbatim, metadata only.booleanWhether the App holds the file paused; the state isUploadState.PAUSEDwhile this orpausedByClientis set, and the servlet refuses chunks while this one is.booleanWhether the client has reported the file paused; a chunk from it clears this.longUncompressed bytes acknowledged.The failure, refusal, cancellation or pause reason, empty for none.final StringThe reservation ID.final StringSHA-256 of the secret, lower-case hex.final longThe declared uncompressed size in bytes.The state.final StringThe declared media type, lower case, empty for none.final intThe format version this record was read with or will be written with.The verified media type, empty until verification or when not sniffable.Constructor Summary
ConstructorsConstructorDescriptionFileRecord(String rid, int fid, String name, String type, long size, long mod, String comp, String group, String secretHash, UploadState state, String reason, long now) Constructor for a new file record.Method Summary
Modifier and TypeMethodDescriptionstatic FileRecordfromJSON(JSONObject jo) Deserializes from JSON.booleanisGzip()Checks if the file uses gzip.toJSON()Serializes to JSON.toString()Outputs to string, without the client's name.
Field Details
version
public final int versionThe format version this record was read with or will be written with.rid
The reservation ID.fid
public final int fidThe file index inside the reservation.name
The client's original name, verbatim, metadata only.type
The declared media type, lower case, empty for none.size
public final long sizeThe declared uncompressed size in bytes.mod
public final long modThe client's last-modified time in milliseconds, 0 if unknown.comp
The compression:gzipornone.group
The group name, empty for none.secretHash
SHA-256 of the secret, lower-case hex.hwm
public long hwmCompressed bytes acknowledged: the valid length of the part.plainHwm
public long plainHwmUncompressed bytes acknowledged.chunks
public int chunksChunks acknowledged, i.e. the next chunk index.state
The state.vtype
The verified media type, empty until verification or when not sniffable.measuredSize
public long measuredSizeThe uncompressed size measured at verification, -1 until then.reason
The failure, refusal, cancellation or pause reason, empty for none.pausedByApp
public boolean pausedByAppWhether the App holds the file paused; the state isUploadState.PAUSEDwhile this orpausedByClientis set, and the servlet refuses chunks while this one is.pausedByClient
public boolean pausedByClientWhether the client has reported the file paused; a chunk from it clears this.lastWrite
public long lastWriteThe last write time in milliseconds.
Constructor Details
FileRecord
public FileRecord(String rid, int fid, String name, String type, long size, long mod, String comp, String group, String secretHash, UploadState state, String reason, long now) Constructor for a new file record.- Parameters:
rid- The reservation ID.fid- The file index.name- The client's original name.type- The declared media type.size- The declared size.mod- The client's last-modified time.comp- The compression.group- The group.secretHash- SHA-256 of the secret, hex; empty for a refused file.state- The initial state.reason- The refusal reason, empty for none.now- The current time.
Method Details
toJSON
fromJSON
Deserializes from JSON.- Parameters:
jo- The JSON object.- Returns:
- The record.
- Throws:
JSONException- If a required field is missing or of the wrong type.IllegalArgumentException- If the state name is unknown.
isGzip
public boolean isGzip()Checks if the file uses gzip.- Returns:
- true for gzip.
toString