mirror of
https://github.com/mirror/jdownloader.git
synced 2024-11-23 12:09:43 +00:00
DownloadLink:
-override setProperties with extended setProperties -new setProperties method to allow keeping of existing properties -some plugins refresh link via old.setProperties(new.getProperties) and that way important properties like jobID or contentURL...were lost -refs post 538630 -TODO: should check plugins if other information must be kept/set? eg progress/pluginmatcherurl.... git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@49632 ebf7c1c2-ba36-0410-9fe8-c592906822b4 Former-commit-id: 2c0dbe46be2c9ddbb39e942524498b165cbd062d
This commit is contained in:
parent
af4af92a65
commit
d105a86b78
@ -24,9 +24,12 @@ import java.lang.reflect.Proxy;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import jd.config.Property;
|
||||
@ -1895,6 +1898,44 @@ public class DownloadLink extends Property implements Serializable, AbstractPack
|
||||
setHashInfo(HashInfo.newInstanceSafe(sha1, HashInfo.TYPE.SHA1));
|
||||
}
|
||||
|
||||
private final static String[] DEFAULT_DO_NOT_CHANGE_EXISTING_KEYS = new String[] { PROPERTY_COMMENT, PROPERTY_MIRRORID, PROPERTY_PASS, PROPERTY_PRIORITY, PROPERTY_LINKDUPEID, PROPERTY_SPEEDLIMIT, PROPERTY_ARCHIVE_ID, URL_ORIGIN, URL_REFERRER, URL_CONTAINER, URL_CONTENT, URL_CUSTOM, PROPERTY_JOB_ID };
|
||||
|
||||
public static String[] getDefaultDoNotChangeExistingKeys() {
|
||||
return DEFAULT_DO_NOT_CHANGE_EXISTING_KEYS.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(final Map<String, Object> properties) {
|
||||
this.setProperties(properties, (String[]) null);
|
||||
}
|
||||
|
||||
public void setProperties(final Map<String, Object> properties, String... doNotChangeExistingKeys) {
|
||||
if (doNotChangeExistingKeys == null) {
|
||||
doNotChangeExistingKeys = DEFAULT_DO_NOT_CHANGE_EXISTING_KEYS;
|
||||
}
|
||||
if (doNotChangeExistingKeys == null || doNotChangeExistingKeys.length == 0 || getPropertiesSize() == 0) {
|
||||
super.setProperties(properties);
|
||||
} else {
|
||||
final Map<String, Object> newProperties = new HashMap<String, Object>();
|
||||
for (String doNotChangeExistingKey : doNotChangeExistingKeys) {
|
||||
final Object value = getProperty(doNotChangeExistingKey);
|
||||
if (value != null) {
|
||||
newProperties.put(doNotChangeExistingKey, value);
|
||||
}
|
||||
}
|
||||
if (newProperties.size() == 0) {
|
||||
super.setProperties(properties);
|
||||
} else {
|
||||
for (final Entry<String, Object> entry : properties.entrySet()) {
|
||||
if (!newProperties.containsKey(entry.getKey())) {
|
||||
newProperties.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
super.setProperties(newProperties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author raztoki
|
||||
* @param sha256
|
||||
|
Loading…
Reference in New Issue
Block a user