[Sugar-devel] [RFC PATCH 2/2] Add migration from DS v0 code for the new properties.
Andrés Ambrois
andresambrois at gmail.com
Sat May 1 14:52:45 EDT 2010
Signed-off-by: Andrés Ambrois <andresambrois at gmail.com>
---
src/carquinyol/migration.py | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/src/carquinyol/migration.py b/src/carquinyol/migration.py
index 95ee391..80adbae 100644
--- a/src/carquinyol/migration.py
+++ b/src/carquinyol/migration.py
@@ -45,8 +45,8 @@ def migrate_from_0():
logging.debug('Migrating entry %r', uid)
try:
- _migrate_metadata(root_path, old_root_path, uid)
_migrate_file(root_path, old_root_path, uid)
+ _migrate_metadata(root_path, old_root_path, uid)
_migrate_preview(root_path, old_root_path, uid)
except Exception:
logging.exception('Error while migrating entry %r', uid)
@@ -73,6 +73,16 @@ def _migrate_metadata(root_path, old_root_path, uid):
metadata['timestamp'] = \
time.mktime(time.strptime(metadata['mtime'], DATE_FORMAT))
+ if 'ctime' not in metadata:
+ metadata['ctime'] = int(os.stat(old_metadata_path).st_ctime)
+
+ file_path = layoutmanager.get_instance().get_data_path(uid)
+ if 'filesize' not in metadata:
+ if os.path.exists(file_path):
+ metadata['filesize'] = int(os.stat(file_path).st_size)
+ else:
+ metadata['filesize'] = 0
+
for key, value in metadata.items():
try:
f = open(os.path.join(metadata_path, key), 'w')
--
1.6.3.3
More information about the Sugar-devel
mailing list