From 577f2bcabf71d41aee183c39abf0fd4886707312 Mon Sep 17 00:00:00 2001 From: Sophist Date: Mon, 23 Sep 2013 15:15:54 +0100 Subject: [PATCH] Fix error when installing over existing plugins As reported in PICARD-444, the following error is received when installing over an existing plugin: Traceback (most recent call last): File ".\picard\ui\options\plugins.py", line 134, in open_plugins self.install_plugin(path) File ".\picard\ui\options\plugins.py", line 148, in install_plugin self.tagger.pluginmanager.install_plugin(path, dest) File ".\picard\plugin.py", line 198, in install_plugin same_file = os.path.samefile(path, dest) if dest_exists else False AttributeError: 'module' object has no attribute 'samefile' --- picard/plugin.py | 3 ++- picard/util/__init__.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/picard/plugin.py b/picard/plugin.py index ef9bb3d5c..45984fe54 100644 --- a/picard/plugin.py +++ b/picard/plugin.py @@ -25,6 +25,7 @@ import picard.plugins import traceback from picard import config, log from picard.const import USER_PLUGIN_DIR +from picard.util import os_path_samefile _suffixes = [s[0] for s in imp.get_suffixes()] @@ -195,7 +196,7 @@ class PluginManager(QtCore.QObject): if plugin_name: try: dest_exists = os.path.exists(dest) - same_file = os.path.samefile(path, dest) if dest_exists else False + same_file = os_path_samefile(path, dest) if dest_exists else False if os.path.isfile(path) and not (dest_exists and same_file): shutil.copy(path, dest) elif os.path.isdir(path) and not same_file: diff --git a/picard/util/__init__.py b/picard/util/__init__.py index 806271084..551d66f7e 100644 --- a/picard/util/__init__.py +++ b/picard/util/__init__.py @@ -400,3 +400,11 @@ def tracknum_from_filename(base_filename): if numbers: return numbers[0] return -1 + +if sys.platform == 'win32': + def os_path_samefile(p1, p2): + ap1 = os.path.abspath(p1) + ap2 = os.path.abspath(p2) + return ap1 == ap2 +else: + os_path_samefile = os.path.samefile