3649: Relative media paths used when creating new media objetcs by drag-and-drop

svn: r17086
This commit is contained in:
Nick Hall 2011-04-09 16:24:48 +00:00
parent 4518d3ca02
commit a716936afa
2 changed files with 6 additions and 0 deletions

View File

@ -472,6 +472,9 @@ class GalleryTab(ButtonTab, DbGUIElement):
if not gen.mime.is_valid_type(mime): if not gen.mime.is_valid_type(mime):
return return
photo = gen.lib.MediaObject() photo = gen.lib.MediaObject()
base_dir = unicode(Utils.media_path(self.dbstate.db))
if os.path.exists(base_dir):
name = Utils.relative_path(name, base_dir)
photo.set_path(name) photo.set_path(name)
photo.set_mime_type(mime) photo.set_mime_type(mime)
basename = os.path.basename(name) basename = os.path.basename(name)

View File

@ -188,6 +188,9 @@ class MediaView(ListView):
if not gen.mime.is_valid_type(mime): if not gen.mime.is_valid_type(mime):
return return
photo = gen.lib.MediaObject() photo = gen.lib.MediaObject()
base_dir = unicode(Utils.media_path(self.dbstate.db))
if os.path.exists(base_dir):
name = Utils.relative_path(name, base_dir)
photo.set_path(name) photo.set_path(name)
photo.set_mime_type(mime) photo.set_mime_type(mime)
basename = os.path.basename(name) basename = os.path.basename(name)