Skip to content

Commit

Permalink
[FIXED JENKINS-18678] - Update builds location in RunMap after the jo…
Browse files Browse the repository at this point in the history
…b's renaming

This change resolve the issue with missing builds after the jobs renaming and further cleanup of cache.
Finally, the cache's directory location will be updated after the each job renaming.
https://issues.jenkins-ci.org/browse/JENKINS-18678

Signed-off-by: Oleg Nenashev <nenashev@synopsys.com>
(cherry picked from commit 568ccba)
  • Loading branch information
oleg-nenashev authored and olivergondza committed Jan 9, 2014
1 parent 412befc commit 65502e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/src/main/java/hudson/model/AbstractProject.java
Expand Up @@ -1659,6 +1659,13 @@ void addToList( T item, List<T> collection ) throws IOException {
updateTransientActions();
}

@Override
public void renameTo(String newName) throws IOException {
super.renameTo(newName);
// Update locations inside builds cache
builds.updateBaseDir(getBuildDir(), false);
}

protected final synchronized <T extends Describable<T>>
void removeFromList(Descriptor<T> item, List<T> collection) throws IOException {
final Iterator<T> iCollection = collection.iterator();
Expand Down Expand Up @@ -2102,6 +2109,7 @@ public HttpResponse doEnable() throws IOException, ServletException {
makeDisabled(false);
return new HttpRedirect(".");
}


/**
* RSS feed for changes in this project.
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
Expand Up @@ -210,6 +210,17 @@ public final boolean baseDirInitialized() {
return dir != null;
}

/**
* Updates base directory location after directory changes.
* This method should be used on jobs renaming, etc.
* @param dir Directory location
* @param reloadBuilds Purges cache after the directory update
*/
public final void updateBaseDir(File dir, boolean reloadBuilds) {
this.dir = dir;
purgeCache();
}

/**
* Let go of all the loaded references.
*
Expand Down

0 comments on commit 65502e1

Please sign in to comment.