From 6212f0c0e3562c3e837d648fc6d02af848ed5f04 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Mon, 10 Mar 2008 19:47:23 +0000 Subject: [PATCH] keep config file's stat info while taking snapshot --- pisi/db/historydb.py | 4 ++-- pisi/operations/history.py | 2 -- pisi/util.py | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pisi/db/historydb.py b/pisi/db/historydb.py index 39204274..919ed30a 100644 --- a/pisi/db/historydb.py +++ b/pisi/db/historydb.py @@ -44,7 +44,7 @@ class HistoryDB(lazydb.LazyDB): self.history.add(pkgBefore, pkgAfter, operation) def load_config(self, operation): - hist_dir = os.path.join(ctx.config.history_dir(), str(operation)) + hist_dir = os.path.join(ctx.config.history_dir(), "%03d" % operation) if os.path.exists(hist_dir): import distutils.dir_util as dir_util dir_util.copy_tree(hist_dir, "/") @@ -56,7 +56,7 @@ class HistoryDB(lazydb.LazyDB): return destdir = os.path.join(hist_dir, config_file[1:]) - pisi.util.copy_file(config_file, destdir); + pisi.util.copy_file_stat(config_file, destdir); def update_history(self): self.history.update() diff --git a/pisi/operations/history.py b/pisi/operations/history.py index 3ce8de5b..40cbdf5d 100644 --- a/pisi/operations/history.py +++ b/pisi/operations/history.py @@ -146,5 +146,3 @@ def takeback(operation): pisi.operations.remove.remove(beremoved) historydb.load_config(operation) - - diff --git a/pisi/util.py b/pisi/util.py index 2e9c3653..c8346bab 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -310,6 +310,12 @@ def copy_file(src,dest): check_dir(os.path.dirname(dest)) shutil.copyfile(src, dest) +def copy_file_stat(src,dest): + """Copy source file to the destination file with all stat info.""" + check_file(src) + check_dir(os.path.dirname(dest)) + shutil.copy2(src, dest) + def is_ar_file(file_path): return open(file_path).read(8) == '!\n'