Download
src.utils.download.get_temporary_file(path: Path, ext: str = '.drive') -> tuple[Path, int]
Check for an existing temporary file representing a provided file path and ext.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | Path | Path to the file we plan to download. | required |
ext | str | Temporary file extension to use, e.g. '.drive' or '.amazon' | '.drive' |
Returns:
Type | Description |
---|---|
tuple[Path, int] | A tuple containing a path to the temporary file and the current size of that file. |
Source code in src\utils\download.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
src.utils.download.download_file(file: Path, res: requests.Response, path: Path = None, callback: Optional[Callable] = None, chunk_size: int = 1024 * 1024) -> bool
Download file from streamed response as a temporary file, then rename to its final path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file | Path | Path of the temporary file. | required |
res | Response | Download request. | required |
path | Path | Final path to save the completed temporary file. | None |
callback | Callable | None | Callback to update download progress. | None |
chunk_size | int | Amount of bytes to download before calling | 1024 * 1024 |
Returns:
Type | Description |
---|---|
bool | True if download completed successfully, otherwise False. |
Source code in src\utils\download.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|