Skip to content

Commit cceb29c

Browse files
author
Vladimir Kotal
committed
make project deletion more robust
1 parent 8b1bb47 commit cceb29c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/ProjectsController.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ public void deleteProject(@PathParam("project") final String projectName)
156156

157157
// Now remove the repositories associated with this project.
158158
List<RepositoryInfo> repos = env.getProjectRepositoriesMap().get(proj);
159-
env.getRepositories().removeAll(repos);
159+
if (repos != null) {
160+
env.getRepositories().removeAll(repos);
161+
}
160162
env.getProjectRepositoriesMap().remove(proj);
161163

162164
env.getProjects().remove(projectName, proj);
@@ -167,9 +169,12 @@ public void deleteProject(@PathParam("project") final String projectName)
167169
// Lastly, remove data associated with the project.
168170
logger.log(Level.INFO, "deleting data for project {0}", projectName);
169171
for (String dirName: new String[]{IndexDatabase.INDEX_DIR, IndexDatabase.XREF_DIR}) {
170-
171-
IOUtils.removeRecursive(Paths.get(env.getDataRootPath() +
172-
File.separator + dirName + File.separator + projectName));
172+
java.nio.file.Path path = Paths.get(env.getDataRootPath(),dirName, projectName);
173+
try {
174+
IOUtils.removeRecursive(path);
175+
} catch (IOException e) {
176+
logger.log(Level.WARNING, "Could not delete {0}", path.toString());
177+
}
173178
}
174179
HistoryGuru guru = HistoryGuru.getInstance();
175180
guru.removeCache(repos.stream().

0 commit comments

Comments
 (0)