zabgrab.services.update

Continuing a file’s fetches from where they left off (zabgrab update).

An update repeats the file’s last fetch from where it ended, with the same items and settings, using the metadata stored with it.

Functions

collect_previous_items(plan, ui, *, connect)

Look up the items fetched before, by ID, to download them again.

plan_update(groups, *, config, ui, now, end, ...)

Work out an update from the last group's metadata.

Classes

UpdatePlan(query, last_group[, servers, ...])

What an update will fetch.

class zabgrab.services.update.UpdatePlan(query, last_group, servers=<factory>, items=<factory>, labels=<factory>)[source]

Bases: object

What an update will fetch.

Parameters:
query

The last fetch’s query, continued from where it ended.

Type:

Query

last_group

The name of the group being continued.

Type:

str

servers

The server to use for each server URL in the group.

Type:

dict of str to Server

items

Item IDs fetched before, with their request labels, by server URL.

Type:

dict of str to list of (int, tuple of str)

labels

Each item’s host: name when it was last fetched, by server URL and item ID, to name items that have since been deleted.

Type:

dict of (str, int) to str

zabgrab.services.update.plan_update(groups, *, config, ui, now, end, end_text, server, file_format)[source]

Work out an update from the last group’s metadata.

Parameters:
  • groups (sequence of Group) – The file’s groups, in order.

  • config (Config) – The config, to find the servers by name (and the jobs and other defaults).

  • ui (UI) – Warns about servers no longer in the config.

  • now (datetime) – The current time.

  • end (datetime or None) – The end of the update (--to), else now.

  • end_text (str or None) – --to as given.

  • server (Server or None) – A server to use instead of the stored one (--server).

  • file_format (Format) – The file’s format.

Returns:

UpdatePlan or None – The plan, or None if there’s nothing to fetch (the file is up to date).

Raises:

ZabgrabError – If there are no groups, or the last one lacks the metadata needed.

Return type:

UpdatePlan | None

async zabgrab.services.update.collect_previous_items(plan, ui, *, connect)[source]

Look up the items fetched before, by ID, to download them again.

Parameters:
  • plan (UpdatePlan) – The update.

  • ui (UI) – Warns about items that no longer exist.

  • connect (callable) – Returns a logged-in client for a server.

Returns:

Plan – The download jobs, with the servers’ connections (close it when done).

Return type:

Plan