Skip to content

Commit

Permalink
Added option to not add new download if previously completed
Browse files Browse the repository at this point in the history
  • Loading branch information
parg committed Jan 2, 2025
1 parent e1101bf commit 4d4e5a4
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 16 deletions.
1 change: 1 addition & 0 deletions core/src/com/biglybt/core/config/ConfigKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public static class File {
/** Despite name, this is the DND file prefix when SCFG_SUBFOLDER_FOR_DND_FILES is true */
public static final String BCFG_USE_INCOMPLETE_FILE_PREFIX = "Use Incomplete File Prefix";
public static final String BCFG_DOWNLOAD_HISTORY_ENABLED = "Download History Enabled";
public static final String BCFG_DOWNLOAD_HISTORY_DONT_ADD_DUP = "Download History Dont Add Duplicate";
public static final String BCFG_FILES_AUTO_TAG_ENABLE = "Files Auto Tag Enable";
public static final String ICFG_FILES_AUTO_TAG_COUNT = "Files Auto Tag Count";
public static final String SCFG_FILE_AUTO_TAG_NAME_DEFAULT = "File Auto Tag Name Default";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ public class ConfigurationDefaults {
def.put(ConfigKeys.StartupShutdown.ICFG_AUTO_RESTART_WHEN_IDLE, ZERO );
def.put(ConfigKeys.StartupShutdown.BCFG_AUTO_RESTART_WHEN_IDLE_PROMPT, TRUE );

def.put( "Download History Enabled", TRUE );
def.put( ConfigKeys.File.BCFG_DOWNLOAD_HISTORY_ENABLED, TRUE );
def.put( ConfigKeys.File.BCFG_DOWNLOAD_HISTORY_DONT_ADD_DUP, FALSE );

// SWT GUI Settings

Expand Down
1 change: 1 addition & 0 deletions core/src/com/biglybt/internat/MessagesBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5582,6 +5582,7 @@ webui.reverse.proxy=Service is behind a reverse proxy
ConfigView.section.file.altloc.dnd=Move files not selected for download to an alternative location
label.row.details=Row Details
MyTorrentsView.menu.row.details={label.row.details}...
ConfigView.label.dl.history.no.dup=Don't add a new download if previously completed

#
#
Expand Down
17 changes: 15 additions & 2 deletions core/src/com/biglybt/ui/config/ConfigSectionFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.biglybt.ui.UIFunctionsManager;
import com.biglybt.ui.UIFunctionsUserPrompter;
import com.biglybt.pif.ui.UIInstance;
import com.biglybt.pif.ui.config.BooleanParameter;
import com.biglybt.pif.ui.config.ConfigSection;
import com.biglybt.pif.ui.config.Parameter;
import com.biglybt.pif.ui.config.ParameterListener;
Expand Down Expand Up @@ -557,9 +558,21 @@ public void build() {

// download history

add(new BooleanParameterImpl(BCFG_DOWNLOAD_HISTORY_ENABLED,
"ConfigView.label.record.dl.history"));
List<Parameter> listDownloadHistory = new ArrayList<>();


BooleanParameter dlh_enable = add(new BooleanParameterImpl(BCFG_DOWNLOAD_HISTORY_ENABLED,
"ConfigView.label.record.dl.history"), listDownloadHistory );

BooleanParameter dlh_no_dup = add(new BooleanParameterImpl(BCFG_DOWNLOAD_HISTORY_DONT_ADD_DUP,
"ConfigView.label.dl.history.no.dup"), listDownloadHistory );

dlh_enable.addEnabledOnSelection(dlh_no_dup);

ParameterGroupImpl pgDownloadHistory = new ParameterGroupImpl( "downloadhistoryview.view.heading", listDownloadHistory );

add("pgDownloadHistory", pgDownloadHistory );

// ignore group

List<Parameter> listIgnoredFiles = new ArrayList<>();
Expand Down
35 changes: 22 additions & 13 deletions uis/src/com/biglybt/ui/swt/shells/main/UIFunctionsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.biglybt.core.Core;
import com.biglybt.core.CoreFactory;
import com.biglybt.core.config.COConfigurationManager;
import com.biglybt.core.config.ConfigKeys;
import com.biglybt.core.config.ParameterListener;
import com.biglybt.core.config.impl.ConfigurationDefaults;
import com.biglybt.core.download.DownloadManager;
Expand Down Expand Up @@ -1428,21 +1429,21 @@ public boolean getHideAll(){
Debug.out( e );
}

if ( !is_silent ){

try{
DownloadHistoryManager dlm = (DownloadHistoryManager)core.getGlobalManager().getDownloadHistoryManager();
try{
DownloadHistoryManager dlm = (DownloadHistoryManager)core.getGlobalManager().getDownloadHistoryManager();

final long[] existing = dlm.getDates( torrentOptions.getTorrent().getHash(), true);
final long[] existing = dlm.getDates( torrentOptions.getTorrent().getHash(), true);

if ( !is_silent ){

if ( existing != null ){

long redownloaded = existing[3];

if ( SystemTime.getCurrentTime() - redownloaded > 60*10*1000 ){

if ( getVisibilityState() != VS_TRAY_ONLY){

forceNotify(STATUSICON_NONE,
MessageText.getString(
"OpenTorrentWindow.mb.inHistory.title"),
Expand All @@ -1451,14 +1452,22 @@ public boolean getHideAll(){
torrentOptions.getTorrentName(),
DisplayFormatters.formatDateYMDHM( existing[0] )
}), null, new Object[0], -1);

}
}
}
}catch( Throwable e ){

Debug.out( e );
}

if ( dlm.isEnabled() && COConfigurationManager.getBooleanParameter( ConfigKeys.File.BCFG_DOWNLOAD_HISTORY_DONT_ADD_DUP )){

if ( existing != null && existing[1] > 0 ){

return( true );
}
}
}catch( Throwable e ){

Debug.out( e );
}
}
}
Expand Down

0 comments on commit 4d4e5a4

Please sign in to comment.