From a253d29d1aedc6139247b4ead2e559696dfd91ba Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 8 Feb 2013 19:19:46 +0000 Subject: [PATCH] improve path info migration --- pandora/archive/migrations/0002_path_info.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pandora/archive/migrations/0002_path_info.py b/pandora/archive/migrations/0002_path_info.py index 1d270143a..5cb3f4784 100644 --- a/pandora/archive/migrations/0002_path_info.py +++ b/pandora/archive/migrations/0002_path_info.py @@ -7,10 +7,17 @@ from django.db import models class Migration(DataMigration): def forwards(self, orm): - for f in orm['archive.File'].objects.exclude(path_info={}): - f.info.update(f.path_info) - f.path_info = {} - f.save() + for f in orm['archive.File'].objects.all(): + update = False + if f.path_info: + f.info.update(f.path_info) + f.path_info = {} + update = True + if not 'extension' in f.info and f.path: + f.info['extension'] = f.path.split('.')[-1] + update = True + if update: + f.save() def backwards(self, orm): "Write your backwards methods here."