luc 9 years ago
commit 6291a57300

@ -74,7 +74,6 @@ public class apkParser extends AbstractParser implements Parser {
Document[] docs = null;
try {
File tempFile = File.createTempFile("apk" + System.currentTimeMillis(), "jar");
tempFile.deleteOnExit();
final FileOutputStream out = new FileOutputStream(tempFile);
int read = 0;
final byte[] data = new byte[1024];

@ -110,7 +110,6 @@ public class audioTagParser extends AbstractParser implements Parser {
} else {
// create a temporary file, as jaudiotagger requires a file rather than an input stream
tempFile = File.createTempFile(filename,fileext);
tempFile.deleteOnExit();
fout = new BufferedOutputStream(new FileOutputStream(tempFile));
int c;
while ((c = source.read()) != -1) {

@ -82,7 +82,6 @@ public class bzipParser extends AbstractParser implements Parser {
final BZip2CompressorInputStream zippedContent = new BZip2CompressorInputStream(source);
tempFile = File.createTempFile("bunzip","tmp");
tempFile.deleteOnExit();
// creating a temp file to store the uncompressed data
final FileOutputStream out = new FileOutputStream(tempFile);

@ -80,7 +80,6 @@ public class gzipParser extends AbstractParser implements Parser {
final GZIPInputStream zippedContent = new GZIPInputStream(source);
tempFile = File.createTempFile("gunzip","tmp");
tempFile.deleteOnExit();
// creating a temp file to store the uncompressed data
final FileOutputStream out = new FileOutputStream(tempFile);

@ -229,7 +229,6 @@ public class odtParser extends AbstractParser implements Parser {
try {
// creating a tempfile
dest = File.createTempFile("OpenDocument", ".odt");
dest.deleteOnExit();
// copying the stream into a file
FileUtils.copy(source, dest);

@ -215,7 +215,6 @@ public class ooxmlParser extends AbstractParser implements Parser {
try {
// creating a tempfile
dest = File.createTempFile("OpenDocument", ".odt");
dest.deleteOnExit();
// copying the stream into a file
FileUtils.copy(source, dest);

@ -63,6 +63,7 @@ import net.yacy.document.VocabularyScraper;
import net.yacy.kelondro.io.CharBuffer;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.util.MemoryControl;
import org.apache.pdfbox.pdfparser.PDFParser;
public class pdfParser extends AbstractParser implements Parser {
@ -100,13 +101,13 @@ public class pdfParser extends AbstractParser implements Parser {
// create a pdf parser
PDDocument pdfDoc;
//final PDFParser pdfParser;
try {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY); // the pdfparser is a big pain
pdfDoc = PDDocument.load(source);
//PDFParser pdfParser = new PDFParser(source);
//pdfParser.parse();
//pdfDoc = pdfParser.getPDDocument();
//pdfDoc = PDDocument.load(source);
final PDFParser pdfParser = new PDFParser(source);
pdfParser.setTempDirectory(new File(System.getProperty("java.io.tmpdir")));
pdfParser.parse();
pdfDoc = pdfParser.getPDDocument();
} catch (final IOException e) {
throw new Parser.Failure(e.getMessage(), location);
} finally {

@ -113,7 +113,7 @@ public class psParser extends AbstractParser implements Parser {
"", // publisher
null, // sections
null, // abstract
0.0f, 0.0f,
0.0d, 0.0d,
outputFile, // fulltext
null, // anchors
null, // rss
@ -125,12 +125,11 @@ public class psParser extends AbstractParser implements Parser {
} catch (final Exception e) {
if (e instanceof InterruptedException) throw (InterruptedException) e;
if (e instanceof Parser.Failure) throw (Parser.Failure) e;
// delete temp file
if (outputFile != null) FileUtils.deletedelete(outputFile);
// throw exception
throw new Parser.Failure("Unexpected error while parsing ps file. " + e.getMessage(),location);
} finally {
// delete temp file
if (outputFile != null) FileUtils.deletedelete(outputFile);
}
}

@ -819,7 +819,6 @@ public final class FileUtils {
File.createTempFile(
parserClassName + "_" + ((idx > -1) ? fileName.substring(0, idx) : fileName),
(!fileExt.isEmpty()) ? "." + fileExt : fileExt);
tempFile.deleteOnExit();
return tempFile;
}

@ -832,7 +832,6 @@ public final class SeedDB implements AlternativeDomainNames {
try {
// create a seed file which for uploading ...
seedFile = File.createTempFile("seedFile",".txt", seedDB.myOwnSeedFile.getParentFile());
seedFile.deleteOnExit();
if (Network.log.isFine()) Network.log.fine("SaveSeedList: Storing seedlist into tempfile " + seedFile.toString());
final ArrayList<String> uv = storeSeedList(seedFile, true);

@ -128,6 +128,7 @@ public final class yacy {
* @param startupFree free memory at startup time, to be used later for statistics
*/
private static void startup(final File dataHome, final File appHome, final long startupMemFree, final long startupMemTotal, final boolean gui) {
String tmpdir=null;
try {
// start up
System.out.println(copyright);
@ -202,6 +203,12 @@ public final class yacy {
lock = channel.tryLock(); // lock yacy.running
} catch (final Exception e) { }
// set jvm tmpdir to a subdir for easy cleanup (as extensive use file.deleteonexit waists memory during long runs, as todelete files names are collected and never cleaned up during runtime)
try {
tmpdir = java.nio.file.Files.createTempDirectory("yacy-tmp-").toString(); // creates sub dir in jvm's temp (see System.property "java.io.tempdir")
System.setProperty("java.io.tmpdir", tmpdir);
} catch (IOException ex) { }
try {
sb = new Switchboard(dataHome, appHome, "defaults/yacy.init".replace("/", File.separator), conf);
} catch (final RuntimeException e) {
@ -386,6 +393,8 @@ public final class yacy {
} finally {
}
if (tmpdir != null) FileUtils.deletedelete(new File(tmpdir)); // clean up temp dir (set at startup as subdir of system.propery "java.io.tmpdir")
ConcurrentLog.config("SHUTDOWN", "goodbye. (this is the last line)");
ConcurrentLog.shutdown();
shutdownSemaphore.release(1000);

Loading…
Cancel
Save