MCPcopy Create free account
hub / github.com/exercism/cli / MigrateLegacyMetadataFile

Method MigrateLegacyMetadataFile

workspace/exercise.go:104–121  ·  view source on GitHub ↗

MigrateLegacyMetadataFile migrates a legacy metadata file to the modern location. This is a noop if the metadata file isn't legacy. If both legacy and modern metadata files exist, the legacy file will be deleted.

()

Source from the content-addressed store, hash-verified

102// This is a noop if the metadata file isn't legacy.
103// If both legacy and modern metadata files exist, the legacy file will be deleted.
104func (e Exercise) MigrateLegacyMetadataFile() (MigrationStatus, error) {
105 if ok, _ := e.HasLegacyMetadata(); !ok {
106 return MigrationStatusNoop, nil
107 }
108 if err := os.MkdirAll(filepath.Dir(e.MetadataFilepath()), os.FileMode(0755)); err != nil {
109 return MigrationStatusNoop, err
110 }
111 if ok, _ := e.HasMetadata(); !ok {
112 if err := os.Rename(e.LegacyMetadataFilepath(), e.MetadataFilepath()); err != nil {
113 return MigrationStatusNoop, err
114 }
115 return MigrationStatusMigrated, nil
116 }
117 if err := os.Remove(e.LegacyMetadataFilepath()); err != nil {
118 return MigrationStatusNoop, err
119 }
120 return MigrationStatusRemoved, nil
121}

Calls 4

HasLegacyMetadataMethod · 0.95
MetadataFilepathMethod · 0.95
HasMetadataMethod · 0.95