Linkhut. Archiving
(linkhut v0.1.8)
View Source
Link archiving context. Handles creating snapshots of bookmarked pages and storing them.
Summary
Functions
Returns the list of content types accepted for snapshot uploads.
Returns true while an Archiver job for link is live or one of its
snapshots is pending or crawling.
Returns true if the user can create new archives.
Returns true if the user can view/download existing archives. Any active user can view when archiving isn't disabled.
Deletes a single snapshot's storage and database record.
Returns :ok on success, {:error, reason} on failure.
Returns the list of users eligible for archiving based on the current mode.
Enqueues a SnapshotDeleter job for each snapshot in pending_deletion state.
Enqueues a re-crawl of link.
Returns a complete snapshot by ID, or {:error, :not_found}.
Returns all complete snapshots for a link.
Returns all crawl runs for a link.
Returns all non-deleted snapshots for a link, ordered by format locality then recency.
Returns the latest complete snapshot of a link in format, for a given
source (when given).
Gets a snapshot by its ID.
Records that a crawler's snapshot reached a terminal state.
Marks all snapshots for a link as pending deletion.
Returns the archiving mode.
Marks a single snapshot as pending deletion.
Stores the file at path as snapshot's content, if and only if it is
within max_file_size.
Updates a snapshot's attributes.
Uploads a user-provided snapshot for a link.
Functions
Returns the list of content types accepted for snapshot uploads.
@spec archiving?(Linkhut.Links.Link.t()) :: boolean()
Returns true while an Archiver job for link is live or one of its
snapshots is pending or crawling.
@spec can_create_archives?(Linkhut.Accounts.User.t()) :: boolean()
Returns true if the user can create new archives.
@spec can_view_archives?(Linkhut.Accounts.User.t()) :: boolean()
Returns true if the user can view/download existing archives. Any active user can view when archiving isn't disabled.
Deletes a single snapshot's storage and database record.
Returns :ok on success, {:error, reason} on failure.
Returns the list of users eligible for archiving based on the current mode.
:disabled→ empty list:limited→ users with an active supporter subscription:enabled→ all active users
Enqueues a SnapshotDeleter job for each snapshot in pending_deletion state.
Enqueues a re-crawl of link.
Returns a complete snapshot by ID, or {:error, :not_found}.
Returns all complete snapshots for a link.
Returns all crawl runs for a link.
Returns all non-deleted snapshots for a link, ordered by format locality then recency.
Returns the latest complete snapshot of a link in format, for a given
source (when given).
Gets a snapshot by its ID.
@spec mark_snapshot( Linkhut.Archiving.Snapshot.t(), :complete | :not_available | :failed, map() ) :: {:ok, Linkhut.Archiving.Snapshot.t()} | {:error, Ecto.Changeset.t() | :not_found}
Records that a crawler's snapshot reached a terminal state.
If the state of this snapshot is as good or better than the state of a prior snapshot for the same link and format, then it marks those older snapshots for deletion:
:completetrumps:complete,:not_availableand:failed:not_availabletrumps:not_availableand:failed:failedtrumps:failed
Note: A crawler's snapshot never replaces an upload.
Marks all snapshots for a link as pending deletion.
Returns the archiving mode.
:disabled: no archiving features:enabled: archiving for all active users:limited: archiving only for active paying users
Marks a single snapshot as pending deletion.
@spec store_file(Linkhut.Archiving.Snapshot.t(), Path.t(), String.t()) :: {:ok, map()} | {:error, {:file_too_large, non_neg_integer(), non_neg_integer()}} | {:error, term()}
Stores the file at path as snapshot's content, if and only if it is
within max_file_size.
Updates a snapshot's attributes.
Uploads a user-provided snapshot for a link.
Detects the format from the content type and supersedes older snapshots of the same format (meaning that uploads always trump prior uploads and any snapshots produced by crawlers).