Skip to content

Commit

Permalink
Refactor simplify migration logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jdsutherland committed Aug 29, 2018
1 parent 9cd6e4c commit b555a3a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions workspace/exercise.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func (e Exercise) MigrateLegacyMetadataFile() (MigrationStatus, error) {
if ok, _ := e.HasLegacyMetadata(); !ok {
return MigrationStatusNoop, nil
}
var status MigrationStatus
legacyMetadataFilepath := e.LegacyMetadataFilepath()
if err := os.MkdirAll(
filepath.Join(filepath.Dir(legacyMetadataFilepath), ignoreSubdir),
Expand All @@ -109,13 +108,10 @@ func (e Exercise) MigrateLegacyMetadataFile() (MigrationStatus, error) {
if err := os.Rename(legacyMetadataFilepath, e.MetadataFilepath()); err != nil {
return MigrationStatusRenameError, err
}
status = MigrationStatusMigrated
return MigrationStatusMigrated, nil
}
if ok, _ := e.HasLegacyMetadata(); ok {
if err := os.Remove(legacyMetadataFilepath); err != nil {
return MigrationStatusRemoveError, err
}
status = MigrationStatusRemoved
if err := os.Remove(legacyMetadataFilepath); err != nil {
return MigrationStatusRemoveError, err
}
return status, nil
return MigrationStatusRemoved, nil
}

0 comments on commit b555a3a

Please sign in to comment.