Skip to content

Commit

Permalink
0003269: If a file exists in staging with a done or create suffix and no
Browse files Browse the repository at this point in the history
period to separate the suffix, then the server won't startup
  • Loading branch information
chenson42 committed Oct 3, 2017
1 parent 6cfd2ff commit b0577ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Expand Up @@ -91,10 +91,14 @@ public StagedResource(File directory, String path, StagingManager stagingManager
protected static String toPath(File directory, File file) {
String path = file.getAbsolutePath();
path = path.replaceAll("\\\\", "/");
path = path.substring(directory.getAbsolutePath().length(), file
.getAbsolutePath().length());
path = path.substring(1, path.lastIndexOf("."));
return path;
path = path.substring(directory.getAbsolutePath().length(), file.getAbsolutePath().length());
int extensionIndex = path.lastIndexOf(".");
if (extensionIndex > 0) {
path = path.substring(1, extensionIndex);
return path;
} else {
throw new IllegalStateException("Expected an extension of .done or .create at the end of the path and did not find it: " + path);
}
}

@Override
Expand Down
Expand Up @@ -66,11 +66,11 @@ public Set<String> getResourceReferences() {

private void refreshResourceList() {
Collection<File> files = FileUtils.listFiles(this.directory,
new String[] { State.CREATE.getExtensionName(), State.DONE.getExtensionName(), State.DONE.getExtensionName() }, true);
new String[] { State.CREATE.getExtensionName(), State.DONE.getExtensionName() }, true);
for (File file : files) {
try {
String path = StagedResource.toPath(directory, file);
if (!resourcePaths.contains(path)) {
if (path != null && !resourcePaths.contains(path)) {
resourcePaths.add(path);
}
} catch (IllegalStateException ex) {
Expand Down

0 comments on commit b0577ff

Please sign in to comment.