2015-01-15 22:43:41 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// MPAlgorithmV3
|
|
|
|
//
|
|
|
|
// Created by Maarten Billemont on 13/01/15.
|
|
|
|
// Copyright 2015 lhunath (Maarten Billemont). All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MPAlgorithmV3.h"
|
|
|
|
#import "MPEntities.h"
|
|
|
|
|
|
|
|
@implementation MPAlgorithmV3
|
|
|
|
|
|
|
|
- (MPAlgorithmVersion)version {
|
|
|
|
|
|
|
|
return MPAlgorithmVersion3;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)tryMigrateSite:(MPSiteEntity *)site explicit:(BOOL)explicit {
|
|
|
|
|
2015-02-28 15:01:41 +00:00
|
|
|
if ([site.algorithm version] != [self version] - 1)
|
2015-01-15 22:43:41 +00:00
|
|
|
// Only migrate from previous version.
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
if (!explicit) {
|
2015-02-28 15:01:41 +00:00
|
|
|
if (site.type & MPSiteTypeClassGenerated &&
|
2017-04-01 04:30:25 +00:00
|
|
|
site.user.name.length != [site.user.name dataUsingEncoding:NSUTF8StringEncoding].length) {
|
2015-01-15 22:43:41 +00:00
|
|
|
// 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;
|
2015-01-15 22:43:41 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|