macearl / Wallhaven-Downloader

A simple download Script for Wallhaven.cc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Self-solved issue explained (half downloaded wallpapers)

WyattLW opened this issue · comments

i was looking thru the downloadWallpapers function and i noticed that the script writes the wallpaper number in the "downloaded.txt" file before actually downloading those, if you CTRL+C the script while it's running you have a chance to interrupt an image download and that one will be skipped next time you start the script.
Meaning you will have corrupted wallpapers here and there (or half downloaded anyway).

to solve just change this: (line 153-ish)

echo "$imgURL" >> downloaded.txt
downloadWallpaper "$imgURL"

to

downloadWallpaper "$imgURL"
echo "$imgURL" >> downloaded.txt

Maybe i missed something, i'm not really good at scripting but it seems to be working this way.

(might also need to add -c (continue download) to the wget commands in script, depends on preferences)

You are right, the same problem occurs for the parallel version.

Furthermore the script should also check if downloadWallpaper returns ok before writing the id to the file

I changed some things and it worked fine during my tests, however im not sure how gnu parallel handles writing to a single file by multiple processes