Skip to content

Commit 1eec2be

Browse files
committed
don't restart too early
1 parent 4bfe742 commit 1eec2be

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/bkg.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,29 +160,20 @@ main() {
160160
awk -F'|' '{print $2}' packages_to_update
161161
)" | sort -u >all_owners_tu
162162

163-
grep -Fxf all_owners_tu "$connections" >connections_tu
164-
165-
if [ ! -s connections_tu ]; then
166-
set_BKG BKG_BATCH_FIRST_STARTED "$today"
167-
rm -f packages_to_update
168-
\cp packages_all packages_to_update
169-
: >packages_already_updated
170-
fi
171-
172163
echo "$(
173164
echo "0/$GITHUB_OWNER"
174165
175166
# new connections
176167
cat "$temp_connections"
177168
178169
# connections that have to be updated
179-
cat connections_tu
170+
grep -Fxf all_owners_tu "$connections"
180171
181172
# requests
182173
cat "$BKG_OWNERS"
183174
)" >"$BKG_OWNERS"
184175

185-
rm -f all_owners_in_db all_owners_tu connections_tu
176+
rm -f all_owners_in_db all_owners_tu
186177
clean_owners "$BKG_OWNERS"
187178
head -n $(($(wc -l <"$connections") + 2)) "$BKG_OWNERS" | env_parallel --lb save_owner
188179
awk -F'|' '{print $1"/"$2}' packages_to_update | sort -uR 2>/dev/null | head -n1000 | env_parallel --lb save_owner

src/lib/owner.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ request_owner() {
2727
return_code=2
2828
elif $paging && [ -n "$id" ]; then
2929
echo "Requested $owner"
30-
set_BKG BKG_LAST_SCANNED_ID "$id"
30+
local last_id
31+
last_id=$(get_BKG BKG_LAST_SCANNED_ID)
32+
(( id <= last_id )) || set_BKG BKG_LAST_SCANNED_ID "$id"
3133
fi
3234

3335
rm -f "$BKG_OWNERS.lock"
@@ -49,8 +51,10 @@ page_owner() {
4951

5052
if [ -n "$GITHUB_TOKEN" ]; then
5153
echo "Checking owners page $1..."
52-
users_more=$(query_api "users?per_page=100&page=$1&since=$(get_BKG BKG_LAST_SCANNED_ID)")
53-
orgs_more=$(query_api "organizations?per_page=100&page=$1&since=$(get_BKG BKG_LAST_SCANNED_ID)")
54+
local last_id
55+
last_id=$(get_BKG BKG_LAST_SCANNED_ID)
56+
users_more=$(query_api "users?per_page=100&page=$1&since=$last_id")
57+
orgs_more=$(query_api "organizations?per_page=100&page=$1&since=$last_id")
5458
owners_more=$(jq --argjson users "$users_more" --argjson orgs "$orgs_more" -n '$users + $orgs | unique_by(.login)')
5559
fi
5660

0 commit comments

Comments
 (0)