diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index e7c6e807a..1c56fe245 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2006-02-12 Alex Roitman + * src/plugins/ReadPkg.py (impData): Use persistent directory for + unpacking the tarball: we need images to stay there. + 2006-02-11 Don Allingham * src/GrampsMime.py: detect directory type * src/ImageSelect.py: don't allow directory types to be added diff --git a/gramps2/src/plugins/ReadPkg.py b/gramps2/src/plugins/ReadPkg.py index f0508faca..7dffaa3c9 100644 --- a/gramps2/src/plugins/ReadPkg.py +++ b/gramps2/src/plugins/ReadPkg.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2000-2006 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,44 +55,51 @@ import TarFile #------------------------------------------------------------------------- def impData(database, name,cb=None,cl=0): # Create tempdir, if it does not exist, then check for writability - tmpdir_path = os.path.expanduser("~/.gramps/tmp" ) + # THE TEMP DIR is named as the filname.gpkg.media and is created + # in the same dir as the database that we are importing into. + db_path = os.path.dirname(database.get_save_path()) + media_dir = "%s.media" % os.path.basename(name) + tmpdir_path = os.path.join(db_path,media_dir) if not os.path.isdir(tmpdir_path): try: os.mkdir(tmpdir_path,0700) except: ErrorDialog( _("Could not create temporary directory %s") % - tmpdir_path ) + tmpdir_path ) return elif not os.access(tmpdir_path,os.W_OK): - ErrorDialog( _("Temporary directory %s is not writable") % tmpdir_path ) + ErrorDialog(_("Temporary directory %s is not writable") % tmpdir_path) return else: # tempdir exists and writable -- clean it up if not empty files = os.listdir(tmpdir_path) ; for filename in files: - os.remove( os.path.join(tmpdir_path,filename) ) + os.remove(os.path.join(tmpdir_path,filename)) try: t = TarFile.ReadTarFile(name,tmpdir_path) t.extract() t.close() except: - ErrorDialog(_("Error extracting into %s") % tmpdir_path ) + ErrorDialog(_("Error extracting into %s") % tmpdir_path) return - dbname = os.path.join(tmpdir_path,const.xmlFile) + imp_db_name = os.path.join(tmpdir_path,const.xmlFile) try: - ReadXML.importData(database,dbname,cb) + ReadXML.importData(database,imp_db_name,cb) except: import DisplayTrace DisplayTrace.DisplayTrace() # Clean up tempdir after ourselves - files = os.listdir(tmpdir_path) - for filename in files: - os.remove(os.path.join(tmpdir_path,filename)) + # THIS HAS BEEN CHANGED, because now we want to keep images + # stay after the import is over. Just delete the XML file. + os.remove(imp_db_name) - os.rmdir(tmpdir_path) +## files = os.listdir(tmpdir_path) +## for filename in files: +## os.remove(os.path.join(tmpdir_path,filename)) +## os.rmdir(tmpdir_path) #------------------------------------------------------------------------ #