|
37 | 37 | import java.util.zip.ZipInputStream; |
38 | 38 | import java.util.zip.ZipOutputStream; |
39 | 39 |
|
| 40 | +import jd.config.Property; |
| 41 | +import jd.controlling.TaskQueue; |
| 42 | +import jd.controlling.downloadcontroller.DownloadController; |
| 43 | +import jd.controlling.downloadcontroller.DownloadSession; |
| 44 | +import jd.controlling.downloadcontroller.DownloadWatchDog; |
| 45 | +import jd.controlling.downloadcontroller.DownloadWatchDogJob; |
| 46 | +import jd.controlling.linkchecker.LinkChecker; |
| 47 | +import jd.controlling.linkchecker.LinkCheckerHandler; |
| 48 | +import jd.controlling.linkcollector.autostart.AutoStartManager; |
| 49 | +import jd.controlling.linkcrawler.CheckableLink; |
| 50 | +import jd.controlling.linkcrawler.CrawledLink; |
| 51 | +import jd.controlling.linkcrawler.CrawledLinkModifier; |
| 52 | +import jd.controlling.linkcrawler.CrawledLinkProperty; |
| 53 | +import jd.controlling.linkcrawler.CrawledPackage; |
| 54 | +import jd.controlling.linkcrawler.CrawledPackage.TYPE; |
| 55 | +import jd.controlling.linkcrawler.LinkCrawler; |
| 56 | +import jd.controlling.linkcrawler.LinkCrawlerDeepInspector; |
| 57 | +import jd.controlling.linkcrawler.LinkCrawlerFilter; |
| 58 | +import jd.controlling.linkcrawler.LinkCrawlerHandler; |
| 59 | +import jd.controlling.linkcrawler.LinkCrawlerRule; |
| 60 | +import jd.controlling.linkcrawler.LinkCrawlerRule.RULE; |
| 61 | +import jd.controlling.linkcrawler.PackageInfo; |
| 62 | +import jd.controlling.packagecontroller.AbstractNode; |
| 63 | +import jd.controlling.packagecontroller.AbstractPackageChildrenNodeFilter; |
| 64 | +import jd.controlling.packagecontroller.PackageController; |
| 65 | +import jd.controlling.packagecontroller.PackageControllerQueue.ReadOnlyQueueAction; |
| 66 | +import jd.gui.swing.jdgui.JDGui; |
| 67 | +import jd.gui.swing.jdgui.WarnLevel; |
| 68 | +import jd.http.Browser; |
| 69 | +import jd.http.URLConnectionAdapter; |
| 70 | +import jd.parser.Regex; |
| 71 | +import jd.plugins.CrawledLinkStorable; |
| 72 | +import jd.plugins.CrawledPackageStorable; |
| 73 | +import jd.plugins.DownloadLink; |
| 74 | +import jd.plugins.FilePackage; |
| 75 | +import jd.plugins.Plugin; |
| 76 | +import jd.plugins.PluginForHost; |
| 77 | +import jd.utils.JDUtilities; |
| 78 | + |
40 | 79 | import org.appwork.controlling.SingleReachableState; |
41 | 80 | import org.appwork.exceptions.WTFException; |
42 | 81 | import org.appwork.scheduler.DelayedRunnable; |
|
53 | 92 | import org.appwork.storage.config.handler.KeyHandler; |
54 | 93 | import org.appwork.uio.UIOManager; |
55 | 94 | import org.appwork.utils.Application; |
| 95 | +import org.appwork.utils.DebugMode; |
56 | 96 | import org.appwork.utils.Files; |
57 | 97 | import org.appwork.utils.IO; |
58 | 98 | import org.appwork.utils.JVMVersion; |
|
112 | 152 | import org.jdownloader.settings.staticreferences.CFG_LINKGRABBER; |
113 | 153 | import org.jdownloader.translate._JDT; |
114 | 154 |
|
115 | | -import jd.config.Property; |
116 | | -import jd.controlling.TaskQueue; |
117 | | -import jd.controlling.downloadcontroller.DownloadController; |
118 | | -import jd.controlling.downloadcontroller.DownloadSession; |
119 | | -import jd.controlling.downloadcontroller.DownloadWatchDog; |
120 | | -import jd.controlling.downloadcontroller.DownloadWatchDogJob; |
121 | | -import jd.controlling.linkchecker.LinkChecker; |
122 | | -import jd.controlling.linkchecker.LinkCheckerHandler; |
123 | | -import jd.controlling.linkcollector.autostart.AutoStartManager; |
124 | | -import jd.controlling.linkcrawler.CheckableLink; |
125 | | -import jd.controlling.linkcrawler.CrawledLink; |
126 | | -import jd.controlling.linkcrawler.CrawledLinkModifier; |
127 | | -import jd.controlling.linkcrawler.CrawledLinkProperty; |
128 | | -import jd.controlling.linkcrawler.CrawledPackage; |
129 | | -import jd.controlling.linkcrawler.CrawledPackage.TYPE; |
130 | | -import jd.controlling.linkcrawler.LinkCrawler; |
131 | | -import jd.controlling.linkcrawler.LinkCrawlerDeepInspector; |
132 | | -import jd.controlling.linkcrawler.LinkCrawlerFilter; |
133 | | -import jd.controlling.linkcrawler.LinkCrawlerHandler; |
134 | | -import jd.controlling.linkcrawler.LinkCrawlerRule; |
135 | | -import jd.controlling.linkcrawler.LinkCrawlerRule.RULE; |
136 | | -import jd.controlling.linkcrawler.PackageInfo; |
137 | | -import jd.controlling.packagecontroller.AbstractNode; |
138 | | -import jd.controlling.packagecontroller.AbstractPackageChildrenNodeFilter; |
139 | | -import jd.controlling.packagecontroller.PackageController; |
140 | | -import jd.gui.swing.jdgui.JDGui; |
141 | | -import jd.gui.swing.jdgui.WarnLevel; |
142 | | -import jd.http.Browser; |
143 | | -import jd.http.URLConnectionAdapter; |
144 | | -import jd.parser.Regex; |
145 | | -import jd.plugins.CrawledLinkStorable; |
146 | | -import jd.plugins.CrawledPackageStorable; |
147 | | -import jd.plugins.DownloadLink; |
148 | | -import jd.plugins.FilePackage; |
149 | | -import jd.plugins.Plugin; |
150 | | -import jd.plugins.PluginForHost; |
151 | | -import jd.utils.JDUtilities; |
152 | | - |
153 | 155 | public class LinkCollector extends PackageController<CrawledPackage, CrawledLink> implements LinkCheckerHandler<CrawledLink>, LinkCrawlerHandler, ShutdownVetoListener { |
154 | 156 | public static final String SOURCE_VARIANT_ID = "SOURCE_VARIANT_ID"; |
155 | 157 | private final WeakHashMap<JobLinkCrawler, Object> jobLinkCrawlers = new WeakHashMap<JobLinkCrawler, Object>(); |
@@ -528,7 +530,7 @@ public String toString() { |
528 | 530 | }); |
529 | 531 | final LinkCollectorConfig cfg = JsonConfig.create(LinkCollectorConfig.class); |
530 | 532 | this.isDupeManagerEnabled = cfg.isDupeManagerEnabled(); |
531 | | - final long minimumDelay = Math.max(5000, cfg.getMinimumSaveDelay()); |
| 533 | + final long minimumDelay = Math.max(DebugMode.TRUE_IN_IDE_ELSE_FALSE ? 1 : 5000, cfg.getMinimumSaveDelay()); |
532 | 534 | long maximumDelay = cfg.getMaximumSaveDelay(); |
533 | 535 | if (maximumDelay <= 0) { |
534 | 536 | maximumDelay = -1; |
@@ -1465,9 +1467,9 @@ protected Void run() throws RuntimeException { |
1465 | 1467 |
|
1466 | 1468 | /* |
1467 | 1469 | * converts a CrawledPackage into a FilePackage |
1468 | | - * |
| 1470 | + * |
1469 | 1471 | * if plinks is not set, then the original children of the CrawledPackage will get added to the FilePackage |
1470 | | - * |
| 1472 | + * |
1471 | 1473 | * if plinks is set, then only plinks will get added to the FilePackage |
1472 | 1474 | */ |
1473 | 1475 | private FilePackage createFilePackage(final CrawledPackage pkg, List<CrawledLink> plinks) { |
@@ -2365,9 +2367,10 @@ public synchronized byte[] toByteArray() { |
2365 | 2367 | * @param file |
2366 | 2368 | */ |
2367 | 2369 | private void save(final List<CrawledPackage> packages, final File destFile) { |
2368 | | - QUEUE.add(new QueueAction<Void, RuntimeException>(Queue.QueuePriority.HIGH) { |
| 2370 | + QUEUE.add(new ReadOnlyQueueAction<Void, RuntimeException>(Queue.QueuePriority.HIGH) { |
2369 | 2371 | @Override |
2370 | 2372 | protected Void run() throws RuntimeException { |
| 2373 | + final boolean isShuttingDown = ShutdownController.getInstance().isShuttingDown(); |
2371 | 2374 | File file = destFile; |
2372 | 2375 | if (file == null) { |
2373 | 2376 | if (linkcollectorLists.size() > 0) { |
@@ -2494,6 +2497,12 @@ public void flush() throws IOException { |
2494 | 2497 | } |
2495 | 2498 | int childIndex = 0; |
2496 | 2499 | for (final CrawledLink link : pkg.getChildren()) { |
| 2500 | + if (!isShuttingDown && DebugMode.TRUE_IN_IDE_ELSE_FALSE) { |
| 2501 | + final QueueAction<?, ? extends Throwable> waiting = LinkCollector.this.getQueue().peek(); |
| 2502 | + if (waiting instanceof ReadOnlyQueueAction) { |
| 2503 | + LinkCollector.this.getQueue().executeQueuedAction(waiting); |
| 2504 | + } |
| 2505 | + } |
2497 | 2506 | final CrawledLinkStorable linkStorable = new CrawledLinkStorable(link); |
2498 | 2507 | CrawledPackageMappingID id = null; |
2499 | 2508 | switch (pkg.getType()) { |
@@ -2692,11 +2701,10 @@ public static enum MoveLinksMode { |
2692 | 2701 | } |
2693 | 2702 |
|
2694 | 2703 | /** |
2695 | | - * This class describes, how a "move links to downloadlist" action shall behave. </br> |
2696 | | - * Examples of what it can influence: </br> |
2697 | | - * - define specific properties that should be set on the items to move e.g. set highest priority </br> |
2698 | | - * - define what should happen afterwards such as "force download-start of added items" </br> |
2699 | | - * - define what happens in linkgrabber afterwards such as "clean all remaining items in linkgrabber" |
| 2704 | + * This class describes, how a "move links to downloadlist" action shall behave. </br> Examples of what it can influence: </br> - define |
| 2705 | + * specific properties that should be set on the items to move e.g. set highest priority </br> - define what should happen afterwards |
| 2706 | + * such as "force download-start of added items" </br> - define what happens in linkgrabber afterwards such as |
| 2707 | + * "clean all remaining items in linkgrabber" |
2700 | 2708 | */ |
2701 | 2709 | public final static class ConfirmLinksSettings { |
2702 | 2710 | public final MoveLinksMode getMoveLinksMode() { |
@@ -3407,7 +3415,7 @@ private CrawledLink putCrawledLinkByLinkID(final String linkID, final CrawledLin |
3407 | 3415 | } |
3408 | 3416 |
|
3409 | 3417 | public boolean containsLinkId(final String linkID) { |
3410 | | - return linkID != null && Boolean.TRUE.equals(getQueue().addWait(new QueueAction<Boolean, RuntimeException>() { |
| 3418 | + return linkID != null && Boolean.TRUE.equals(getQueue().addWait(new ReadOnlyQueueAction<Boolean, RuntimeException>() { |
3411 | 3419 | @Override |
3412 | 3420 | protected Boolean run() throws RuntimeException { |
3413 | 3421 | return getCrawledLinkByLinkID(linkID) != null; |
|
0 commit comments