diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index e619d00a31..b4e347a9af 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -409,8 +409,8 @@ def relpath(target, base=os.curdir): target_list = (os.path.abspath(target)).split(os.sep) # On the windows platform the target may be on a completely different drive from the base. - if iswindows and base_list[0] != target_list[0]: - raise OSError, 'Target is on a different drive to base. Target: '+target_list[0].upper()+', base: '+base_list[0].upper() + if iswindows and base_list[0].upper() != target_list[0].upper(): + raise OSError, 'Target is on a different drive to base. Target: '+repr(target)+', base: '+repr(base) # Starting from the filepath root, work out how much of the filepath is # shared by base and target. diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py index eacc4f04e0..7807c66a86 100644 --- a/src/calibre/ebooks/metadata/__init__.py +++ b/src/calibre/ebooks/metadata/__init__.py @@ -83,7 +83,10 @@ class Resource(object): frag = '#'+quote(self.fragment) if self.fragment else '' if self.path == basedir: return ''+frag - rpath = relpath(self.path, basedir) + try: + rpath = relpath(self.path, basedir) + except OSError: # On windows path and basedir could be on different drives + rpath = self.path return quote(rpath.replace(os.sep, '/'))+frag