|
38 | 38 |
|
39 | 39 | import java.io.BufferedInputStream;
|
40 | 40 | import java.io.File;
|
41 |
| -import java.io.IOException; |
42 | 41 | import java.io.InputStream;
|
43 | 42 | import java.util.ArrayList;
|
44 | 43 | import java.util.Collection;
|
@@ -124,20 +123,15 @@ public FileWorkArea initializeWorkArea() {
|
124 | 123 | @Override
|
125 | 124 | public void closeWorkArea(FileWorkArea fwArea) {
|
126 | 125 | File tempDirectory = new File(fwArea.getFilePathLocation());
|
127 |
| - try { |
128 |
| - if (tempDirectory.exists()) { |
129 |
| - FileUtils.deleteDirectory(tempDirectory); |
130 |
| - } |
| 126 | + if (tempDirectory.exists()) { |
| 127 | + FileUtils.deleteQuietly(tempDirectory); |
| 128 | + } |
131 | 129 |
|
132 |
| - for (int i = 1; i < maxGeneratedDirectoryDepth; i++) { |
133 |
| - tempDirectory = tempDirectory.getParentFile(); |
134 |
| - if (tempDirectory.list().length == 0 && tempDirectory.exists()) { |
135 |
| - FileUtils.deleteDirectory(tempDirectory); |
136 |
| - } |
| 130 | + for (int i = 0; i < maxGeneratedDirectoryDepth; i++) { |
| 131 | + tempDirectory = tempDirectory.getParentFile(); |
| 132 | + if (!tempDirectory.delete()) { |
| 133 | + break; |
137 | 134 | }
|
138 |
| - |
139 |
| - } catch (IOException ioe) { |
140 |
| - throw new FileServiceException("Unable to delete temporary working directory for " + tempDirectory, ioe); |
141 | 135 | }
|
142 | 136 | }
|
143 | 137 |
|
@@ -358,14 +352,19 @@ protected String getTempDirectory(String baseDirectory) {
|
358 | 352 | for (int i = 0; i < maxGeneratedDirectoryDepth; i++) {
|
359 | 353 | if (i == 4) {
|
360 | 354 | LOG.warn("Property asset.server.max.generated.file.system.directories set to high, currently set to " +
|
361 |
| - maxGeneratedDirectoryDepth); |
| 355 | + maxGeneratedDirectoryDepth + " ignoring and only creating 4 levels."); |
362 | 356 | break;
|
363 | 357 | }
|
364 | 358 | // check next int value
|
365 | 359 | int num = random.nextInt(256);
|
366 | 360 | baseDirectory = FilenameUtils.concat(baseDirectory, Integer.toHexString(num));
|
367 | 361 | }
|
368 |
| - return baseDirectory; |
| 362 | + |
| 363 | + return FilenameUtils.concat(baseDirectory, buildThreadIdString()); |
| 364 | + } |
| 365 | + |
| 366 | + protected String buildThreadIdString() { |
| 367 | + return Long.toHexString(Thread.currentThread().getId()); |
369 | 368 | }
|
370 | 369 |
|
371 | 370 | /**
|
|
0 commit comments