| 1 |
# Copyright (C) 2008-2010 Adam Olsen |
| 2 |
# |
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 2, or (at your option) |
| 6 |
# any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with this program; if not, write to the Free Software |
| 15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 |
# |
| 17 |
# |
| 18 |
# The developers of the Exaile media player hereby grant permission |
| 19 |
# for non-GPL compatible GStreamer and Exaile plugins to be used and |
| 20 |
# distributed together with GStreamer and Exaile. This permission is |
| 21 |
# above and beyond the permissions granted by the GPL license by which |
| 22 |
# Exaile is covered. If you modify this code, you may extend this |
| 23 |
# exception to your version of the code, but you are not obligated to |
| 24 |
# do so. If you do not wish to do so, delete this exception statement |
| 25 |
# from your version. |
| 26 |
|
| 27 |
from gi.repository import Gio |
| 28 |
|
| 29 |
|
| 30 |
def migrate(db, pdata, oldversion, newversion): |
| 31 |
for k in (x for x in pdata.keys() if x.startswith("tracks-")): |
| 32 |
p = pdata[k] |
| 33 |
tags = p[0] |
| 34 |
try: |
| 35 |
loc = tags['__loc'] |
| 36 |
except KeyError: |
| 37 |
continue |
| 38 |
if not loc or not loc.startswith("file://"): |
| 39 |
continue |
| 40 |
loc = loc[7:] |
| 41 |
gloc = Gio.File.new_for_uri(loc) |
| 42 |
uri = gloc.get_uri() |
| 43 |
tags['__loc'] = uri |
| 44 |
pdata[k] = (tags, p[1], p[2]) |
| 45 |
|
| 46 |
if '_serial_libraries' in pdata: |
| 47 |
libs = pdata['_serial_libraries'] |
| 48 |
for l in libs: |
| 49 |
l['location'] = Gio.File.new_for_uri(l['location']).get_uri() |
| 50 |
pdata['_serial_libraries'] = libs |
| 51 |
|
| 52 |
pdata['_dbversion'] = newversion |
| 53 |
pdata.sync() |