07837: Incorrect media path when using drag & drop; backport from gramps41; incomplete for non-ascii path or filename

This commit is contained in:
Jérôme Rapinat 2014-07-17 14:41:44 +02:00
parent 85fd4a8502
commit 3dcdddf039

View File

@ -523,13 +523,14 @@ class GalleryTab(ButtonTab, DbGUIElement):
d = conv_to_unicode((file.replace('\0',' ').strip()), None)
protocol, site, mfile, j, k, l = urlparse(d)
if protocol == "file":
mime = get_type(mfile)
name = url2pathname(mfile)
mime = get_type(name)
if not is_valid_type(mime):
return
photo = MediaObject()
base_dir = cuni(media_path(self.dbstate.db))
if os.path.exists(base_dir):
name = relative_path(mfile, base_dir)
name = relative_path(name, base_dir)
photo.set_path(name)
photo.set_mime_type(mime)
basename = os.path.basename(name)