2014-09-24 11:58:23 +00:00
|
|
|
/**
|
|
|
|
* Copyright Maarten Billemont (http://www.lhunath.com, lhunath@lyndir.com)
|
|
|
|
*
|
|
|
|
* See the enclosed file LICENSE for license information (LGPLv3). If you did
|
|
|
|
* not receive this file, see http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
|
|
*
|
|
|
|
* @author Maarten Billemont <lhunath@lyndir.com>
|
|
|
|
* @license http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
2015-01-15 22:43:41 +00:00
|
|
|
// MPAlgorithmV2
|
2014-09-24 11:58:23 +00:00
|
|
|
//
|
|
|
|
// Created by Maarten Billemont on 17/07/12.
|
|
|
|
// Copyright 2012 lhunath (Maarten Billemont). All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MPAlgorithmV2.h"
|
|
|
|
#import "MPEntities.h"
|
|
|
|
|
|
|
|
@implementation MPAlgorithmV2
|
|
|
|
|
2015-01-15 22:43:41 +00:00
|
|
|
- (MPAlgorithmVersion)version {
|
2014-09-24 11:58:23 +00:00
|
|
|
|
2015-01-15 22:43:41 +00:00
|
|
|
return MPAlgorithmVersion2;
|
2014-09-24 11:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)tryMigrateSite:(MPSiteEntity *)site explicit:(BOOL)explicit {
|
|
|
|
|
2015-02-28 15:01:41 +00:00
|
|
|
if ([site.algorithm version] != [self version] - 1)
|
2014-09-24 11:58:23 +00:00
|
|
|
// Only migrate from previous version.
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
if (!explicit) {
|
|
|
|
if (site.type & MPSiteTypeClassGenerated && site.name.length != [site.name dataUsingEncoding:NSUTF8StringEncoding].length) {
|
|
|
|
// This migration requires explicit permission for types of the generated class.
|
|
|
|
site.requiresExplicitMigration = YES;
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply migration.
|
|
|
|
site.requiresExplicitMigration = NO;
|
2015-02-28 15:01:41 +00:00
|
|
|
site.algorithm = self;
|
2014-09-24 11:58:23 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|