mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-25 23:06:22 +02:00
Merge stop test only if error or completed #1882
https://github.com/RipMeApp/ripme/pull/1882
This commit is contained in:
@@ -138,7 +138,7 @@ public abstract class AbstractHTMLRipper extends AbstractRipper {
|
|||||||
index += 1;
|
index += 1;
|
||||||
LOGGER.debug("Found image url #" + index + ": " + imageURL);
|
LOGGER.debug("Found image url #" + index + ": " + imageURL);
|
||||||
downloadURL(new URL(imageURL), index);
|
downloadURL(new URL(imageURL), index);
|
||||||
if (isStopped()) {
|
if (isStopped() || isThisATest()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ public abstract class AbstractHTMLRipper extends AbstractRipper {
|
|||||||
if (!textURLs.isEmpty()) {
|
if (!textURLs.isEmpty()) {
|
||||||
LOGGER.debug("Found description link(s) from " + doc.location());
|
LOGGER.debug("Found description link(s) from " + doc.location());
|
||||||
for (String textURL : textURLs) {
|
for (String textURL : textURLs) {
|
||||||
if (isStopped()) {
|
if (isStopped() || isThisATest()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
textindex += 1;
|
textindex += 1;
|
||||||
@@ -303,10 +303,10 @@ public abstract class AbstractHTMLRipper extends AbstractRipper {
|
|||||||
Queues multiple URLs of single images to download from a single Album URL
|
Queues multiple URLs of single images to download from a single Album URL
|
||||||
*/
|
*/
|
||||||
public boolean addURLToDownload(URL url, File saveAs, String referrer, Map<String,String> cookies, Boolean getFileExtFromMIME) {
|
public boolean addURLToDownload(URL url, File saveAs, String referrer, Map<String,String> cookies, Boolean getFileExtFromMIME) {
|
||||||
// Only download one file if this is a test.
|
// Only download one file if this is a test.
|
||||||
if (super.isThisATest() &&
|
if (super.isThisATest() && (itemsCompleted.size() > 0 || itemsErrored.size() > 0)) {
|
||||||
(itemsPending.size() > 0 || itemsCompleted.size() > 0 || itemsErrored.size() > 0)) {
|
|
||||||
stop();
|
stop();
|
||||||
|
itemsPending.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!allowDuplicates()
|
if (!allowDuplicates()
|
||||||
|
@@ -142,10 +142,10 @@ public abstract class AbstractJSONRipper extends AbstractRipper {
|
|||||||
* Queues multiple URLs of single images to download from a single Album URL
|
* Queues multiple URLs of single images to download from a single Album URL
|
||||||
*/
|
*/
|
||||||
public boolean addURLToDownload(URL url, File saveAs, String referrer, Map<String,String> cookies, Boolean getFileExtFromMIME) {
|
public boolean addURLToDownload(URL url, File saveAs, String referrer, Map<String,String> cookies, Boolean getFileExtFromMIME) {
|
||||||
// Only download one file if this is a test.
|
// Only download one file if this is a test.
|
||||||
if (super.isThisATest() &&
|
if (super.isThisATest() && (itemsCompleted.size() > 0 || itemsErrored.size() > 0)) {
|
||||||
(itemsPending.size() > 0 || itemsCompleted.size() > 0 || itemsErrored.size() > 0)) {
|
|
||||||
stop();
|
stop();
|
||||||
|
itemsPending.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!allowDuplicates()
|
if (!allowDuplicates()
|
||||||
|
@@ -14,9 +14,12 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import org.jsoup.HttpStatusException;
|
import org.jsoup.HttpStatusException;
|
||||||
import com.rarchives.ripme.App;
|
import com.rarchives.ripme.App;
|
||||||
import com.rarchives.ripme.ui.RipStatusComplete;
|
import com.rarchives.ripme.ui.RipStatusComplete;
|
||||||
@@ -48,17 +51,18 @@ public abstract class AbstractRipper
|
|||||||
public boolean hasASAPRipping() { return false; }
|
public boolean hasASAPRipping() { return false; }
|
||||||
// Everytime addUrlToDownload skips a already downloaded url this increases by 1
|
// Everytime addUrlToDownload skips a already downloaded url this increases by 1
|
||||||
public int alreadyDownloadedUrls = 0;
|
public int alreadyDownloadedUrls = 0;
|
||||||
private boolean shouldStop = false;
|
private final AtomicBoolean shouldStop = new AtomicBoolean(false);
|
||||||
private static boolean thisIsATest = false;
|
private static boolean thisIsATest = false;
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
shouldStop = true;
|
LOGGER.trace("stop()");
|
||||||
|
shouldStop.set(true);
|
||||||
}
|
}
|
||||||
public boolean isStopped() {
|
public boolean isStopped() {
|
||||||
return shouldStop;
|
return shouldStop.get();
|
||||||
}
|
}
|
||||||
protected void stopCheck() throws IOException {
|
protected void stopCheck() throws IOException {
|
||||||
if (shouldStop) {
|
if (shouldStop.get()) {
|
||||||
throw new IOException("Ripping interrupted");
|
throw new IOException("Ripping interrupted");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,10 +51,10 @@ public abstract class AlbumRipper extends AbstractRipper {
|
|||||||
* Queues multiple URLs of single images to download from a single Album URL
|
* Queues multiple URLs of single images to download from a single Album URL
|
||||||
*/
|
*/
|
||||||
public boolean addURLToDownload(URL url, File saveAs, String referrer, Map<String,String> cookies, Boolean getFileExtFromMIME) {
|
public boolean addURLToDownload(URL url, File saveAs, String referrer, Map<String,String> cookies, Boolean getFileExtFromMIME) {
|
||||||
// Only download one file if this is a test.
|
// Only download one file if this is a test.
|
||||||
if (super.isThisATest() &&
|
if (super.isThisATest() && (itemsCompleted.size() > 0 || itemsErrored.size() > 0)) {
|
||||||
(itemsPending.size() > 0 || itemsCompleted.size() > 0 || itemsErrored.size() > 0)) {
|
|
||||||
stop();
|
stop();
|
||||||
|
itemsPending.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!allowDuplicates()
|
if (!allowDuplicates()
|
||||||
|
@@ -39,6 +39,13 @@ public class RippersTest {
|
|||||||
ripper.setup();
|
ripper.setup();
|
||||||
ripper.markAsTest();
|
ripper.markAsTest();
|
||||||
ripper.rip();
|
ripper.rip();
|
||||||
|
if (logger.isTraceEnabled()) {
|
||||||
|
logger.trace("working dir: " + ripper.getWorkingDir());
|
||||||
|
logger.trace("list files: " + ripper.getWorkingDir().listFiles().length);
|
||||||
|
for (int i = 0; i < ripper.getWorkingDir().listFiles().length; i++) {
|
||||||
|
logger.trace(" " + ripper.getWorkingDir().listFiles()[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Assertions.assertTrue(ripper.getWorkingDir().listFiles().length >= 1,
|
Assertions.assertTrue(ripper.getWorkingDir().listFiles().length >= 1,
|
||||||
"Failed to download a single file from " + ripper.getURL());
|
"Failed to download a single file from " + ripper.getURL());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Reference in New Issue
Block a user