Skip to content

Commit

Permalink
Merge pull request #234 from czechboy0/hd/fixed_migration
Browse files Browse the repository at this point in the history
Bugfix in migration
  • Loading branch information
czechboy0 committed Feb 4, 2016
2 parents ac29f39 + cd4df60 commit b4eb27c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion BuildaKit/Persistence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ public class Persistence {
let contents = try self.fileManager.contentsOfDirectoryAtURL(folderUrl, includingPropertiesForKeys: nil, options: [.SkipsHiddenFiles, .SkipsSubdirectoryDescendants])
return contents
} catch {
Log.error("Couldn't read folder \(folderUrl), error \(error)")
if (error as NSError).code != 260 { //ignore not found errors
Log.error("Couldn't read folder \(folderUrl), error \(error)")
}
return nil
}
}
Expand Down
14 changes: 11 additions & 3 deletions BuildaKit/PersistenceMigrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ public class CompositeMigrator: MigratorType {
}

public func attemptMigration() throws {
try self.childMigrators
.filter { $0.isMigrationRequired() }
.forEach { try $0.attemptMigration() }

//if we find a required migration, we need to also run all
//the ones that come after it
for (idx, mig) in self.childMigrators.enumerate() {
if mig.isMigrationRequired() {
let toRun = self.childMigrators.suffixFrom(idx)
print("Performing \(toRun.count) migrations")
try toRun.forEach { try $0.attemptMigration() }
break
}
}
}
}

Expand Down

0 comments on commit b4eb27c

Please sign in to comment.