From bd18302d69064eb7090ba10de637c3a5d38601a9 Mon Sep 17 00:00:00 2001 From: Peter Landgren Date: Tue, 3 Nov 2009 17:33:35 +0000 Subject: [PATCH] Fix so that a copy is created, if new filename already exists. Works like normal XML export. svn: r13494 --- src/plugins/export/ExportPkg.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/export/ExportPkg.py b/src/plugins/export/ExportPkg.py index 11e50cfb3..411786f12 100644 --- a/src/plugins/export/ExportPkg.py +++ b/src/plugins/export/ExportPkg.py @@ -31,6 +31,7 @@ # #------------------------------------------------------------------------- import time +import shutil import os import sys import tarfile @@ -69,6 +70,17 @@ import Utils # #------------------------------------------------------------------------- def writeData(database, filename, option_box=None, callback=None): + +# Rename file, if it exists already, with .bak +# as it it for normal XML export. + + if os.path.isfile(filename): + try: + shutil.copyfile(filename, filename + ".bak") + shutil.copystat(filename, filename + ".bak") + except: + pass + if option_box: option_box.parse_options()