Add resilience/retry when writing to disk
I would like to suggest an enchancement/feature request, about adding resiliency for those of us who have intermittent glitched/network issues and a failure occurs when wrting directly to a NAS the downloaded content.
From time to time the execution fails witht the following traceback:
Traceback (most recent call last): File "U:\Private\Scraping\OnlyFans\tool\helpers\main_helper.py", line 996, in write_data OSError: [Errno 22] Invalid argument
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "U:\Private\Scraping\OnlyFans\tool\start_ofd.py", line 60, in
File "C:\Python39\WPy64-3920\python-3.9.2.amd64\lib\asyncio\base_events.py", line 642, in run_until_complete return future.result() File "U:\Private\Scraping\OnlyFans\tool\start_ofd.py", line 44, in main File "U:\Private\Scraping\OnlyFans\tool\datascraper\main_datascraper.py", line 102, in start_datascraper File "U:\Private\Scraping\OnlyFans\tool\helpers\main_helper.py", line 948, in process_downloads File "U:\Private\Scraping\OnlyFans\tool\modules\onlyfans.py", line 1248, in prepare_downloads File "U:\Private\Scraping\OnlyFans\tool\helpers\main_helper.py", line 248, in async_downloads File "U:\Private\Scraping\OnlyFans\tool\helpers\main_helper.py", line 243, in run File "U:\Private\Scraping\OnlyFans\tool\helpers\main_helper.py", line 220, in process_download File "U:\Private\Scraping\OnlyFans\tool\helpers\main_helper.py", line 1003, in write_data OSError: [Errno 22] Invalid argument
My idea? Have a configurable number of attempts, and amount of time to sleep/wait between each attempts to write to disk. So for example, via configuration, I could tell the scrapper to attempt writing 10 times, waiting for 5 seconds between each attempts, before giving up and crashing for good. All while still printing the crash on every attempt for logging purpose.
Such resiliance baked in would be very helpful in my case. I haven't checked, but I suspect I end-up with corrupted/half downloaded files when those crash occurs? And if so, are they even being resumed/re-downloaded later? Also, having to manually monitor the process just to relaunch it every few hours can be a pain.
Oh!, That's something I have been wondering about myself. - If a download fails, or corrupts, or photo half downloads. Regardless of where the corruption occurs via the download pipe or the write to disk action. On subsequent runs of the scraper, are these files resumed/re-downloaded?
You could download the content to your machine and copy it to the NAS once its done and keep the metadata in a separate folder (see #1575).