[Piuparts-commits] [SCM] piuparts git repository branch, piatti, updated. 0.48-19-g93bfc2b

Andreas Beckmann debian at abeckmann.de
Sat Dec 1 10:50:58 UTC 2012


The following commit has been merged in the piatti branch:
commit 701db2401cf6905daf283131cb2b10e8809e4785
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Fri Nov 30 14:26:49 2012 +0100

    p-r: hardlink the logfiles to the htdocs tree
    
    should reduce the I/O load of -report and disk space usage
    
    fallback to copying if linking does not work (i.e. over filesystem
    boundaries)
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/TODO b/TODO
index ac805d5..c0c1002 100644
--- a/TODO
+++ b/TODO
@@ -43,9 +43,6 @@ for 0.48:
 - slave_run: cleanup stale proc mountpoints
   -> there is ~piupartss/bin/slave_cleanup which should be executed at the beginning of slave_run
 
-- consider hardlinking instead of copying the logfiles to htdocs
-  (and fall back to copying if linking fails)
-
 
 for 0.49:
 
diff --git a/debian/changelog b/debian/changelog
index c9e1d9d..5b835de 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,7 @@ piuparts (0.49) UNRELEASED; urgency=low
   * piuparts-master.py:
   * piuparts-slave.py:
   * piuparts-report.py:
+    - Hardlink the logfiles to the htdocs tree (with copy as fallback).
   * New bug template: partial-upgrade-file-overwrite.
 
  -- Andreas Beckmann <debian at abeckmann.de>  Fri, 30 Nov 2012 13:11:25 +0100
diff --git a/piuparts-report.py b/piuparts-report.py
index 68da29d..a0b7ea8 100644
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@ -483,13 +483,20 @@ def update_file(source, target):
         except OSError:
             pass
         else:
-            if aa.st_size == bb.st_size and aa.st_mtime < bb.st_mtime:
+            if aa.st_size == bb.st_size and aa.st_mtime <= bb.st_mtime:
                 return
+        try:
+            os.remove(target)
+        except:
+            pass
     try:
-        shutil.copyfile(source, target)
-    except IOError as (errno, strerror):
-        logging.error("failed to copy %s to %s: I/O error(%d): %s" \
-                       % (source, target, errno, strerror))
+        os.link(source, target)
+    except OSError:
+        try:
+            shutil.copyfile(source, target)
+        except IOError as (errno, strerror):
+            logging.error("failed to copy %s to %s: I/O error(%d): %s" \
+                           % (source, target, errno, strerror))
 
 
 def copy_logs(logs_by_dir, output_dir):

-- 
piuparts git repository



More information about the Piuparts-commits mailing list