@@ -163,32 +163,18 @@ func modifyRepositoryURL(newRepositoryURL string) error {
163163
164164 fmt .Printf ("Changing URL of library %s from %s to %s\n " , libraryName , oldRepositoryURL , newRepositoryURL )
165165
166- // Move the library Git clone to the new path.
167- gitClonePath := func (url string ) (* paths.Path , error ) {
168- libraryRegistration := libraries.Repo {URL : url }
169- gitCloneSubfolder , err := libraryRegistration .AsFolder ()
170- if err != nil {
171- return nil , err
172- }
173-
174- return paths .New (config .GitClonesFolder , gitCloneSubfolder ), nil
175- }
176- oldGitClonePath , err := gitClonePath (oldRepositoryURL )
166+ // Remove the library Git clone folder. It will be cloned from the new URL on the next sync.
167+ libraryRegistration := libraries.Repo {URL : libraryData .Repository }
168+ gitCloneSubfolder , err := libraryRegistration .AsFolder ()
177169 if err != nil {
178170 return err
179171 }
180- newGitClonePath , err := gitClonePath (newRepositoryURL )
181- if err != nil {
182- return err
183- }
184- if err := newGitClonePath .Parent ().MkdirAll (); err != nil {
185- return fmt .Errorf ("While creating new library Git clone path: %w" , err )
186- }
187- if err := backup .Backup (oldGitClonePath ); err != nil {
172+ gitClonePath := paths .New (config .GitClonesFolder , gitCloneSubfolder )
173+ if err := backup .Backup (gitClonePath ); err != nil {
188174 return fmt .Errorf ("While backing up library's Git clone: %w" , err )
189175 }
190- if err := oldGitClonePath . Rename ( newGitClonePath ); err != nil {
191- return fmt .Errorf ("While moving library's Git clone: %w" , err )
176+ if err := gitClonePath . RemoveAll ( ); err != nil {
177+ return fmt .Errorf ("While removing library's Git clone: %w" , err )
192178 }
193179
194180 // Update the library repository URL in the database.
0 commit comments