Skip to content

Commit

Permalink
Merge branch 'master' of github.com:internetarchive/heritrix3
Browse files Browse the repository at this point in the history
  • Loading branch information
anjackson committed Jun 21, 2021
2 parents 6d0ae8f + 31e54cc commit 33a01a3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 225 deletions.
6 changes: 0 additions & 6 deletions commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>mg4j</artifactId>
<version>1.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.anotherbigidea</groupId>
<artifactId>javaswf</artifactId>
Expand Down
19 changes: 0 additions & 19 deletions commons/src/main/java/org/archive/io/CrawlerJournal.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.archive.io;

import it.unimi.dsi.fastutil.io.FastBufferedOutputStream;
import it.unimi.dsi.mg4j.util.MutableString;

import java.io.Closeable;
import java.io.File;
Expand Down Expand Up @@ -121,24 +120,6 @@ public synchronized void writeLine(String... strs) {
}
}

/**
* Write a line.
*
* @param mstring MutableString to write
*/
public synchronized void writeLine(MutableString mstring) {
if (this.out == null) {
return;
}
try {
mstring.write(out);
this.out.write("\n");
noteLine();
} catch (IOException e) {
LOGGER.log(Level.SEVERE,"problem writing journal line: "+mstring, e);
}
}

/**
* Count and note a line
*
Expand Down
165 changes: 0 additions & 165 deletions dist/src/main/licenses/mg4j-1.0.1.LICENSE

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,17 @@ protected Representation post(Representation entity, Variant variant) throws Res
cancel = true;
}
}
if(!cancel) {
System.exit(0);
}
if (!cancel) {
Flash.addFlash(getResponse(), "Shutting down ... bye");
new Thread(() -> {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
System.exit(0);
}).start();
}
} else if ("gc".equals(action)) {
System.gc();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
*/
package org.archive.modules.fetcher;

import it.unimi.dsi.mg4j.util.MutableString;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Reader;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
Expand Down Expand Up @@ -126,36 +122,29 @@ public void saveCookies(String saveCookiesFile) {
return;
}

FileOutputStream out = null;
try {
out = new FileOutputStream(new File(saveCookiesFile));
try (BufferedWriter out = Files.newBufferedWriter(Paths.get(saveCookiesFile))) {
String tab ="\t";
out.write("# Heritrix Cookie File\n".getBytes());
out.write("# This file is the Netscape cookies.txt format\n\n".getBytes());
out.write("# Heritrix Cookie File\n");
out.write("# This file is the Netscape cookies.txt format\n\n");
for (Cookie cookie: new ArrayList<Cookie>(getCookies())) {
// Guess an initial size
MutableString line = new MutableString(1024 * 2);
line.append(cookie.getDomain());
line.append(tab);
// XXX line.append(cookie.isDomainAttributeSpecified() ? "TRUE" : "FALSE");
line.append("TRUE");
line.append(tab);
line.append(cookie.getPath() != null ? cookie.getPath() : "/");
line.append(tab);
line.append(cookie.isSecure() ? "TRUE" : "FALSE");
line.append(tab);
line.append(cookie.getExpiryDate() != null ? cookie.getExpiryDate().getTime() / 1000 : -1);
line.append(tab);
line.append(cookie.getName());
line.append(tab);
line.append(cookie.getValue() != null ? cookie.getValue() : "");
line.append("\n");
out.write(line.toString().getBytes());
out.write(cookie.getDomain());
out.write(tab);
// XXX out.write(cookie.isDomainAttributeSpecified() ? "TRUE" : "FALSE");
out.write("TRUE");
out.write(tab);
out.write(cookie.getPath() != null ? cookie.getPath() : "/");
out.write(tab);
out.write(cookie.isSecure() ? "TRUE" : "FALSE");
out.write(tab);
out.write(Long.toString(cookie.getExpiryDate() != null ? cookie.getExpiryDate().getTime() / 1000 : -1));
out.write(tab);
out.write(cookie.getName());
out.write(tab);
out.write(cookie.getValue() != null ? cookie.getValue() : "");
out.write("\n");
}
} catch (IOException e) {
logger.log(Level.SEVERE, "Unable to write " + saveCookiesFile, e);
} finally {
IOUtils.closeQuietly(out);
}
}

Expand Down

0 comments on commit 33a01a3

Please sign in to comment.