pld-builder.new: PLD_Builder/srpm_builder.py rename/fsync for max_req_no fi...

arekm arekm at pld-linux.org
Sat Nov 13 22:55:53 CET 2010


Author: arekm                        Date: Sat Nov 13 21:55:52 2010 GMT
Module: pld-builder.new               Tag: HEAD
---- Log message:
rename/fsync for max_req_no file, too

---- Files affected:
pld-builder.new/PLD_Builder:
   srpm_builder.py (1.73 -> 1.74) 

---- Diffs:

================================================================
Index: pld-builder.new/PLD_Builder/srpm_builder.py
diff -u pld-builder.new/PLD_Builder/srpm_builder.py:1.73 pld-builder.new/PLD_Builder/srpm_builder.py:1.74
--- pld-builder.new/PLD_Builder/srpm_builder.py:1.73	Sat Nov 13 22:38:07 2010
+++ pld-builder.new/PLD_Builder/srpm_builder.py	Sat Nov 13 22:55:47 2010
@@ -9,6 +9,7 @@
 import re
 import shutil
 import atexit
+import tempfile
 
 import gpg
 import request
@@ -50,8 +51,8 @@
         return
     r.batches = new_b
     # store new queue and max_req_no for binary builders
-    cnt_f = open(path.max_req_no_file, "r+")
-    num = int(string.strip(cnt_f.read())) + 1
+    num = int(string.strip(open(path.max_req_no_file, "r").read())) + 1
+
     r.no = num
     q = B_Queue(path.req_queue_file)
     q.lock(0)
@@ -62,10 +63,15 @@
     q.dump_html(path.queue_html_stats_file)
     q.write_signed(path.req_queue_signed_file)
     q.unlock()
+
+    (cnt_f, tmpfname) = tempfile.mkstemp(dir=os.path.dirname(path.max_req_no_file))
     cnt_f.seek(0)
     cnt_f.write("%d\n" % num)
+    cnt_f.flush()
+    os.fsync(cnt_f.fileno())
     cnt_f.close()
-    os.chmod(path.max_req_no_file, 0644)
+    os.chmod(tmpfname, 0644)
+    os.rename(tmpfname, path.max_req_no_file)
 
 def transfer_file(r, b):
     local = path.srpms_dir + '/' + r.id + "/" + b.src_rpm
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/srpm_builder.py?r1=1.73&r2=1.74&f=u



More information about the pld-cvs-commit mailing list