1 |
Author: zmedico |
2 |
Date: 2008-05-02 02:28:20 +0000 (Fri, 02 May 2008) |
3 |
New Revision: 10068 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/bin/emerge-webrsync |
7 |
Log: |
8 |
Bug #219837 - Adjust date calculations some more and show an |
9 |
informative ewarn message when bailing out due to a newer |
10 |
snapshot being unavailable. (trunk r10067) |
11 |
|
12 |
|
13 |
Modified: main/branches/2.1.2/bin/emerge-webrsync |
14 |
=================================================================== |
15 |
--- main/branches/2.1.2/bin/emerge-webrsync 2008-05-02 02:27:37 UTC (rev 10067) |
16 |
+++ main/branches/2.1.2/bin/emerge-webrsync 2008-05-02 02:28:20 UTC (rev 10068) |
17 |
@@ -323,28 +323,66 @@ |
18 |
# day, so the current day's snapshot (going by UTC time) hasn't been |
19 |
# generated yet. Therefore, always start by looking for the previous day's |
20 |
# snapshot (for attempts=1, subtract 1 day from the current UTC time). |
21 |
- while (( ${attempts} < 40 )) ; do |
22 |
- local day |
23 |
- local month |
24 |
- local year |
25 |
- local seconds |
26 |
|
27 |
- attempts=$(( ${attempts} + 1 )) |
28 |
+ # Timestamps that differ by less than 2 hours |
29 |
+ # are considered to be approximately equal. |
30 |
+ local min_time_diff=$(( 2 * 60 * 60 )) |
31 |
|
32 |
- utc_attempt=$(expr $(get_utc_date_in_seconds) - 86400 \* ${attempts}) |
33 |
+ local existing_timestamp=$(get_portage_timestamp) |
34 |
+ local timestamp_difference |
35 |
+ local timestamp_problem |
36 |
+ local approx_snapshot_time |
37 |
+ local start_time=$(get_utc_date_in_seconds) |
38 |
+ local start_hour=$(get_date_part ${start_time} "%H") |
39 |
|
40 |
- day=$(get_date_part ${utc_attempt} "%d") |
41 |
- month=$(get_date_part ${utc_attempt} "%m") |
42 |
- year=$(get_date_part ${utc_attempt} "%Y") |
43 |
- utc_midnight=$(expr ${utc_attempt} - ${utc_attempt} % 86400) |
44 |
+ # Daily snapshots are created at 1:45 AM and are not |
45 |
+ # available until after 2 AM. Don't waste time trying |
46 |
+ # to fetch a snapshot before it's been created. |
47 |
+ if [ ${start_hour} -lt 2 ] ; then |
48 |
+ (( start_time -= 86400 )) |
49 |
+ fi |
50 |
+ local snapshot_date=$(get_date_part ${start_time} "%Y%m%d") |
51 |
+ local snapshot_date_seconds=$(get_utc_second_from_string ${snapshot_date}) |
52 |
|
53 |
- if [ ${utc_midnight} -lt $(get_portage_timestamp) ]; then |
54 |
- wecho "portage content is newer than available snapshots (use --revert option to overide)" |
55 |
+ while (( ${attempts} < 40 )) ; do |
56 |
+ (( attempts++ )) |
57 |
+ (( snapshot_date_seconds -= 86400 )) |
58 |
+ # snapshots are created at 1:45 AM |
59 |
+ (( approx_snapshot_time = snapshot_date_seconds + 86400 + 6300 )) |
60 |
+ (( timestamp_difference = existing_timestamp - approx_snapshot_time )) |
61 |
+ [ ${timestamp_difference} -lt 0 ] && (( timestamp_difference = -1 * timestamp_difference )) |
62 |
+ snapshot_date=$(get_date_part ${snapshot_date_seconds} "%Y%m%d") |
63 |
+ |
64 |
+ timestamp_problem="" |
65 |
+ if [ ${timestamp_difference} -eq 0 ]; then |
66 |
+ timestamp_problem="is identical to" |
67 |
+ elif [ ${timestamp_difference} -lt ${min_time_diff} ]; then |
68 |
+ timestamp_problem="is possibly identical to" |
69 |
+ elif [ ${approx_snapshot_time} -lt ${existing_timestamp} ] ; then |
70 |
+ timestamp_problem="is newer than" |
71 |
+ fi |
72 |
+ |
73 |
+ if [ -n "${timestamp_problem}" ]; then |
74 |
+ ewarn "Latest snapshot date: ${snapshot_date}" |
75 |
+ ewarn |
76 |
+ ewarn "Approximate snapshot timestamp: ${approx_snapshot_time}" |
77 |
+ ewarn " Current local timestamp: ${existing_timestamp}" |
78 |
+ ewarn |
79 |
+ echo -e "The current local timestamp" \ |
80 |
+ "${timestamp_problem} the" \ |
81 |
+ "timestamp of the latest" \ |
82 |
+ "snapshot. In order to force sync," \ |
83 |
+ "use the --revert option or remove" \ |
84 |
+ "the timestamp file located at" \ |
85 |
+ "'${PORTDIR}/metadata/timestamp.x'." | fmt -w 70 | \ |
86 |
+ while read line ; do |
87 |
+ ewarn "${line}" |
88 |
+ done |
89 |
r=0 |
90 |
break |
91 |
fi |
92 |
|
93 |
- if do_snapshot 0 "${year}${month}${day}"; then |
94 |
+ if do_snapshot 0 "${snapshot_date}"; then |
95 |
r=0 |
96 |
break; |
97 |
fi |
98 |
|
99 |
-- |
100 |
gentoo-commits@l.g.o mailing list |