diff --git a/src/ReadXML.py b/src/ReadXML.py index 50ed9ba33..1a775106a 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -114,17 +114,18 @@ def importData(database, filename, callback): xml_file.close() # Rename media files if they were conflicting with existing ones - #print parser.MediaFileMap ObjectMap = parser.db.getObjectMap() for OldMediaID in parser.MediaFileMap.keys(): NewMediaID = parser.MediaFileMap[OldMediaID] - oldfile = ObjectMap[NewMediaID].getPath() - oldpath = os.path.dirname(oldfile) - (junk,oldext) = os.path.splitext(os.path.basename(oldfile)) - ObjectMap[NewMediaID].setLocal(1) - if NewMediaID != OldMediaID: + if NewMediaID != OldMediaID: + oldfile = ObjectMap[NewMediaID].getPath() + oldpath = os.path.dirname(oldfile) + (junk,oldext) = os.path.splitext(os.path.basename(oldfile)) + oldfile = os.path.join( basefile, OldMediaID + oldext ) newfile = os.path.join( basefile, NewMediaID + oldext ) os.rename(oldfile,newfile) + ObjectMap[NewMediaID].setPath(os.path.join(oldpath,NewMediaID+oldext)) + ObjectMap[NewMediaID].setLocal(1) return 1 diff --git a/src/plugins/ReadNative.py b/src/plugins/ReadNative.py index f93a14043..849adf304 100644 --- a/src/plugins/ReadNative.py +++ b/src/plugins/ReadNative.py @@ -123,7 +123,7 @@ class ReadNative: for filename in files: oldfile = os.path.join(tmpdir_path,filename) newfile = os.path.join(dbdir_path,filename) - if filename != const.xmlFile: + if filename not in [const.xmlFile,const.xmlFile+'.bak']: shutil.copy2( oldfile, newfile ) os.remove( oldfile ) diff --git a/src/plugins/ReadPkg.py b/src/plugins/ReadPkg.py index cefc089cc..576c64127 100644 --- a/src/plugins/ReadPkg.py +++ b/src/plugins/ReadPkg.py @@ -123,7 +123,7 @@ class ReadPkg: for filename in files: oldfile = os.path.join(tmpdir_path,filename) newfile = os.path.join(dbdir_path,filename) - if filename != const.xmlFile: + if filename not in [const.xmlFile,const.xmlFile+'.bak']: shutil.copy2( oldfile, newfile ) os.remove( oldfile )