import DBDownload from "../database/entities/db-download"; import { DBPost } from "../database/db"; import DBUrl from "../database/entities/db-url"; import Downloader from "./downloader"; import { DownloaderState, DownloadProgress } from "../util/state"; export declare function getDownloaders(): Promise; /** * Find the next DBDownload that needs a URL processed, which is not already inside the given array. * * This is a mutex, and can only be invoked with one concurrent lookup. */ export declare const getNextPendingDownload: (ignoreURLs: Set) => Promise>; /** * Run the downloading process for all unhandled DBUrls, and any that are saved live. */ export declare function downloadAll(state: DownloaderState): Promise; export interface DownloaderData { /** The relative path of this file. Not as useful for Downloaders. */ relativeFile: string; /** The target output file's absolute path */ file: string; /** The target URL, unpacked from dl.url.address for simplicity */ url: string; /** The Post providing this URL */ post: DBPost; /** The DBDownload object providing this URL. */ dl: DBDownload; } export interface DownloaderFunctions { /** Register a new URL, and sets the current URL as an album parent. Noop for nested albums. */ addAlbum: (url: string) => Promise; /** Mark the current URL as failed, and add a reason. The URL will be skipped by default after this. */ markInvalid: (reason: string) => Promise; /** gracefully exit in a way that will be swallowed by the parent error handling. */ userExit: (reason?: string) => void; } /** * Generate the data structure and callbacks that are to be passed into the Downloader instances. */ export declare function buildDownloadData(dl: DBDownload): Promise<{ data: DownloaderData; callbacks: DownloaderFunctions; }>; /** * Iterate through all available downloaders, attempting to handle the given DBDownload. */ export declare function handleDownload(dl: DBDownload, progress: DownloadProgress): Promise; /** * Builds and saves a new DBFile for the given DBUrl and file path. */ export declare function processFinishedDownload(url: DBUrl, subPath: string, handler: string): Promise;