Expand description
Add a PDF the user downloaded themselves to the store (#606).
For a paper with no OA copy, the user downloads it under their own access and wants the store to know, so no other project hits the same wall. What this may and may not check is fixed by ADR-0003: the PDF is an opaque blob, so nothing here reads its text, its metadata streams or its page structure. The checks are the ones a fetch already makes of bytes off the wire, plus one about the file’s name:
- a regular file, not a symlink, starting with
%PDF-, undercrate::PDF_MAX_BYTES; - a file name that is itself a work id –
BF01397394.pdf,PhysRev.34.1293.pdf– must be the id of the ref it is added under. A name like1928-024 PCPS Hartree - The wave mechanics.pdfmakes no claim and is accepted.forceoverrides the mismatch.
The entry is recorded as what it is: [doiget] source = "user",
license = "unknown", origin = "user-supplied" – never as an open
copy, since bib, paper_pdf_path and an agent would otherwise read a
licensed download as free to use. The file is copied, not moved, and the
provenance row names the store path only: the original path, which
carries the user’s home directory, is not logged.
Structs§
- AddOutcome
- What
add_user_pdfstored.
Enums§
- AddError
- Why a file was not added.
Functions§
- add_
user_ pdf - Add
fileto the store asref_’s PDF. - check_
file - Check
filethe way a fetch checks bytes off the wire, and return the bytes that passed – the only ones the store is given. Nothing past the magic number is interpreted (ADR-0003); the bytes are held, as a fetch holds a response body, never parsed. - file_
stem - The file’s name without its
.pdfextension (case-insensitive) and a browser’s duplicate suffix (name (1).pdf). - looks_
like_ an_ id - Whether
stemreads as a work id rather than a description: six or more characters, only letters, digits,.,-and_, and at least one digit.BF01397394,PhysRev.34.1293andrspa.1950.0036are ids;1928-024 PCPS Hartree - The wave mechanicsis not. - match_
file - The one ref in
candidateswhose idstemis, if exactly one (#606--from-dir). Two candidates sharing a DOI suffix is ambiguous and matches none. - stem_
names - Whether
stemnamesref_: the DOI suffix (BF01340294for10.1007/BF01340294), the whole DOI with/as_or-, or the arXiv id with or without a version. Case-insensitive.