diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2018-09-26 15:27:45 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2018-09-26 15:48:26 -0400 |
commit | 013531bb6b11eb250cc897ef487532a34a1da836 (patch) | |
tree | 900d288131e2e76e5954dc7db82d9b5d73d1a41c | |
parent | 45de45b658d33c746fcb25cc469c9d7c1f4d7059 (diff) |
make_repo_torrents: Fixparabola/20180925.2
-rwxr-xr-x | cron-jobs/make_repo_torrents | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/cron-jobs/make_repo_torrents b/cron-jobs/make_repo_torrents index d8613a4..1bf66af 100755 --- a/cron-jobs/make_repo_torrents +++ b/cron-jobs/make_repo_torrents @@ -31,13 +31,28 @@ mkdir -p -- "${FTP_BASE}/${TORRENTPOOL}" IFS=, # for ${TRACKERS[*]} and ${WEBSEEDS[*]} -ret=0 +pool_broken=0 +maintain_pool() { + local pkgfile="$1" + if (( pool_broken )); then + return 0 + fi + local link="${FTP_BASE}/${TORRENTPOOL}/${pkgfile##*/}.torrent" + if [[ -L $link && -f $link ]]; then + return 0 + fi + pkgfile=$(readlink -f -- "$pkgfile") + if ! ln -sfrT -- "${pkgfile}.torrent" "$link"; then + pool_broken=1 + fi +} make_torrent() { local pkgfile="$1" local target if [[ -f ${pkgfile}.torrent ]]; then + maintain_pool "$pkgfile" return 0 fi if ! [[ -f $pkgfile ]]; then @@ -53,7 +68,7 @@ make_torrent() { if [[ -f "${FTP_BASE}/${TORRENTPOOL}/${pkgfile##*/}.torrent" && ! -L "${FTP_BASE}/${TORRENTPOOL}/${pkgfile##*/}.torrent" ]]; then ln -T -- "${FTP_BASE}/${TORRENTPOOL}/${pkgfile##*/}.torrent" "${pkgfile}.torrent" - ln -sfrT -- "${pkgfile}.torrent" "${FTP_BASE}/${TORRENTPOOL}/${pkgfile##*/}.torrent" || ret=$? + maintain_pool "$pkgfile" else msg2 'Creating %s' "${pkgfile}.torrent" mktorrent \ @@ -61,7 +76,7 @@ make_torrent() { --web-seed="${WEBSEEDS[*]/%/"${pkgfile#"${FTP_BASE}"}"}" \ --output="${pkgfile}.torrent" \ -- "${pkgfile}" >/dev/null - ln -sfrT -- "${pkgfile}.torrent" "${FTP_BASE}/${TORRENTPOOL}/${pkgfile##*/}.torrent" || ret=$? + maintain_pool "$pkgfile" fi fi } @@ -71,4 +86,4 @@ for pkgfile in "$FTP_BASE"/*/os/*/*${PKGEXTS}; do make_torrent "$pkgfile" done msg 'Done' -exit $ret +exit $pool_broken |