File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,7 @@ def poll_pull_requests(api):
36
36
total_votes = {}
37
37
fs = fp .read ()
38
38
if fs :
39
- # if the voting record exists, read it in
40
39
total_votes = json .loads (fs )
41
- # then prepare for overwriting
42
- fp .seek (0 )
43
- fp .truncate ()
44
40
45
41
top_contributors = sorted (gh .repos .get_contributors (api , settings .URN ),
46
42
key = lambda user : user ["total" ], reverse = True )
@@ -131,10 +127,15 @@ def poll_pull_requests(api):
131
127
total_votes [user ] += 1
132
128
else :
133
129
total_votes [user ] = 1
134
- json .dump (total_votes , fp )
135
130
136
- # flush all buffers because we might restart, which could cause a crash
137
- os .fsync (fp )
131
+ if fs :
132
+ # prepare for overwriting
133
+ fp .seek (0 )
134
+ fp .truncate ()
135
+ json .dump (total_votes , fp )
136
+
137
+ # flush all buffers because we might restart, which could cause a crash
138
+ os .fsync (fp )
138
139
139
140
# we approved a PR, restart
140
141
if needs_update :
You can’t perform that action at this time.
0 commit comments