Comments (9)
Take a look at https://github.com/frostwire/frostwire-jlibtorrent/blob/master/src/main/java/com/frostwire/jlibtorrent/Session.java#L846
Create one for you (getSwig() is public) and add:
flags &= ~add_torrent_params.flags_t.seed_mode.swigValue();
I don't like a set of a java enum, but I will research how to improve the API in the java layer. We left getSwig() to allow for all sort of low level coding like this case.
from frostwire-jlibtorrent.
Thanks, this helps a lot.
from frostwire-jlibtorrent.
@tchoulihan
TIP: if you ever need to pass the getSwig() reference to another object, try passing a copy of it instead. It happens that the GC may leave you with an invalid reference which often leads to a crash.
from frostwire-jlibtorrent.
I'll keep this in mind.
from frostwire-jlibtorrent.
Sorry to ask about this again, but I'm trying to create a custom add_torrent method where by default, auto_manage is false, and seed_mode is true.
Setting the flags is confusing, because in the settings you appear to be doing bitwise inversions and ORs, instead of setting multiple flags.
Wouldn't this line in your code be turning off automanage, since its using ~(or invert bits)?
https://github.com/frostwire/frostwire-jlibtorrent/blob/master/src/main/java/com/frostwire/jlibtorrent/Session.java#L942
Would this be correct for me then?
// always set automanage to false
add_torrent_params p = add_torrent_params.create_instance();
TorrentInfo ti = new TorrentInfo(torrentFile);
String savePath = outputParent.getAbsolutePath();
p.setTi(ti.getSwig().copy());
p.setSave_path(savePath);
p.setStorage_mode(storage_mode_t.storage_mode_sparse);
long flags = p.getFlags();
if (saveResumeData.exists()) {
byte[] data;
try {
data = Files.readAllBytes(Paths.get(saveResumeData.getAbsolutePath()));
p.setResume_data(Vectors.bytes2char_vector(data));
flags |= add_torrent_params.flags_t.flag_use_resume_save_path.swigValue();
} catch (IOException e) {
e.printStackTrace();
}
}
// Set seed mode
if (seedMode) {
flags &= ~add_torrent_params.flags_t.flag_seed_mode.swigValue();
}
// Turn off automanage
flags &= add_torrent_params.flags_t.flag_auto_managed.swigValue();
p.setFlags(flags);
TorrentHandle torrent = new TorrentHandle(session.getSwig().add_torrent(p));
from frostwire-jlibtorrent.
yes, I believe the intention there is to turn off the automanage.
>>> f = 0b111
>>> f &= ~0b001
>>> bin(f)
'0b110' # bit is turned off
>>> f &= ~0b001
>>> bin(f)
'0b110' # bit remains turned off
from frostwire-jlibtorrent.
I think you can always call TorrentHandle::setAutoManaged, https://github.com/frostwire/frostwire-jlibtorrent/blob/master/src/main/java/com/frostwire/jlibtorrent/TorrentHandle.java#L297
from frostwire-jlibtorrent.
I just figured this out.
So I converted the long to a binary string, figured out which enum_flags_t were turned on by default.
Here are what the bits do:
http://libtorrent.org/reference-Session.html#add_torrent_params
It turns out auto_managed is turned on by default, so you have to do:
flags -= add_torrent_params.flags_t.flag_auto_managed.swigValue();
to turn it off.
And to turn on the others(that aren't already on by default), you can just add the swig values like so:
flags += add_torrent_params.flags_t.flag_seed_mode.swigValue();
Here are the default flags when you run p.getFlags()
:
default flags = 10001001110000
@aldenml , I actually needed to turn off automanage as I add the torrents, because if you try turning it off afterwards, libtorrent still might have paused them before it receives that message for some reason.
from frostwire-jlibtorrent.
It turns out auto_managed is turned on by default, so you have to do:
flags -= add_torrent_params.flags_t.flag_auto_managed.swigValue(); to turn it off.
yeah, which is what we do.
from frostwire-jlibtorrent.
Related Issues (20)
- version mismatch HOT 22
- Force recheck crashing for finished torrent HOT 4
- No implementation found for void com.frostwire.jlibtorrent.swig.libtorrent_jni.swig_module_init() HOT 1
- Adding a download with changed priorities doesn't recognize the new priorities if download was finished earlier. HOT 9
- Downloads are not compatible HOT 4
- Download issues in Samsung Galaxy devices HOT 9
- How to Compile in embedded system, the platform is arm32. HOT 1
- [desktop] Calling SessionManager stop() takes forever after torrent is finished HOT 8
- dhtNodes Always 0 HOT 26
- Docker script Q&A HOT 5
- Error in Vectors.byte_vector2string
- sessionManager.stats().dhtNodes() always 0 HOT 4
- How to merge libraries into one? HOT 2
- Pure virtual function called! On Android 10+ [Using version 1.2.16.0] HOT 1
- Upgrading to libtorrent 2.0, it's time. HOT 1
- Low memory bug HOT 3
- Is it possible use your libtorrent.i wrap a c# version? HOT 11
- native crash HOT 1
- Debugging libtorrent crash on Android HOT 3
- iOS compatibility? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from frostwire-jlibtorrent.