Another try to fix to problem with the open file descriptors
git-svn-id: https://svn.libreccm.org/ccm/trunk@5286 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
9e1d87ee5d
commit
744af4d721
|
|
@ -11,7 +11,7 @@
|
||||||
* implied. See the License for the specific language governing
|
* implied. See the License for the specific language governing
|
||||||
* rights and limitations under the License.
|
* rights and limitations under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.themedirector.util;
|
package com.arsdigita.themedirector.util;
|
||||||
|
|
||||||
import com.arsdigita.themedirector.Theme;
|
import com.arsdigita.themedirector.Theme;
|
||||||
|
|
@ -132,10 +132,11 @@ public class ThemeFileUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try (final DirectoryStream<Path> directoryStream
|
||||||
Files
|
= Files.newDirectoryStream(root)) {
|
||||||
.newDirectoryStream(root)
|
|
||||||
.forEach(path -> prepareThemeFile(path, eligiblePaths));
|
directoryStream.forEach(path -> prepareThemeFile(path,
|
||||||
|
eligiblePaths));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new UncheckedWrapperException(ex);
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
|
|
@ -147,6 +148,7 @@ public class ThemeFileUtil {
|
||||||
if (Files.isDirectory(path)) {
|
if (Files.isDirectory(path)) {
|
||||||
try (final DirectoryStream<Path> directoryStream = Files
|
try (final DirectoryStream<Path> directoryStream = Files
|
||||||
.newDirectoryStream(path)) {
|
.newDirectoryStream(path)) {
|
||||||
|
|
||||||
directoryStream
|
directoryStream
|
||||||
.forEach(current -> prepareThemeFile(current,
|
.forEach(current -> prepareThemeFile(current,
|
||||||
eligiablePaths));
|
eligiablePaths));
|
||||||
|
|
@ -210,24 +212,29 @@ public class ThemeFileUtil {
|
||||||
boolean overwriteNewerFiles,
|
boolean overwriteNewerFiles,
|
||||||
String fileType) {
|
String fileType) {
|
||||||
if (currentFile.isDirectory()) {
|
if (currentFile.isDirectory()) {
|
||||||
|
|
||||||
File[] files = currentFile.listFiles(new WhiteListFilenameFilter());
|
File[] files = currentFile.listFiles(new WhiteListFilenameFilter());
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (int i = 0; i < files.length; i++) {
|
||||||
updateDatabaseFiles(files[i], currentTheme,
|
|
||||||
serverSpecificPath, themeFiles,
|
updateDatabaseFiles(files[i],
|
||||||
overwriteNewerFiles, fileType);
|
currentTheme,
|
||||||
|
serverSpecificPath,
|
||||||
|
themeFiles,
|
||||||
|
overwriteNewerFiles,
|
||||||
|
fileType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (currentFile.exists()) {
|
if (currentFile.exists()) {
|
||||||
|
|
||||||
String fullFilePath = currentFile.getAbsolutePath();
|
String fullFilePath = currentFile.getAbsolutePath();
|
||||||
String filePath = null;
|
String filePath = null;
|
||||||
int beginIndex = fullFilePath.indexOf(serverSpecificPath);
|
int beginIndex = fullFilePath.indexOf(serverSpecificPath);
|
||||||
if (beginIndex > -1 && fullFilePath.length()
|
if (beginIndex > -1
|
||||||
> serverSpecificPath.length()) {
|
&& fullFilePath.length() > serverSpecificPath.length()) {
|
||||||
filePath = fullFilePath.substring(beginIndex
|
filePath = fullFilePath
|
||||||
+ serverSpecificPath
|
.substring(beginIndex + serverSpecificPath.length() + 1);
|
||||||
.length() + 1);
|
|
||||||
} else {
|
} else {
|
||||||
filePath = fullFilePath;
|
filePath = fullFilePath;
|
||||||
}
|
}
|
||||||
|
|
@ -246,14 +253,14 @@ public class ThemeFileUtil {
|
||||||
// Undelete the file if it reappeared
|
// Undelete the file if it reappeared
|
||||||
if (themeFile != null
|
if (themeFile != null
|
||||||
&& themeFile.isDeleted()
|
&& themeFile.isDeleted()
|
||||||
&& themeFile.getLastModifiedDate()
|
&& themeFile
|
||||||
|
.getLastModifiedDate()
|
||||||
.before(new Date(currentFile.lastModified()))) {
|
.before(new Date(currentFile.lastModified()))) {
|
||||||
themeFile.setDeleted(false);
|
themeFile.setDeleted(false);
|
||||||
s_log.info("Undeleting the file: " + currentFile);
|
s_log.info("Undeleting the file: " + currentFile);
|
||||||
}
|
}
|
||||||
try {
|
try (FileInputStream in = new FileInputStream(currentFile);
|
||||||
FileInputStream in = new FileInputStream(currentFile);
|
ByteArrayOutputStream os = new ByteArrayOutputStream()) {
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
byte[] buffer = new byte[8];
|
byte[] buffer = new byte[8];
|
||||||
int length = -1;
|
int length = -1;
|
||||||
|
|
@ -275,8 +282,6 @@ public class ThemeFileUtil {
|
||||||
// we save to help with stack trace issues and so that
|
// we save to help with stack trace issues and so that
|
||||||
// we don't have too many build up.
|
// we don't have too many build up.
|
||||||
themeFile.save();
|
themeFile.save();
|
||||||
in.close();
|
|
||||||
os.close();
|
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
s_log.error("Error opening file reader for " + currentFile
|
s_log.error("Error opening file reader for " + currentFile
|
||||||
.getAbsolutePath(), fnfe);
|
.getAbsolutePath(), fnfe);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue