| Summary: | First and last chunk download priority | ||
|---|---|---|---|
| Product: | [Applications] ktorrent | Reporter: | Byte Smythe <bytesmythe> |
| Component: | general | Assignee: | Joris Guisson <joris.guisson> |
| Status: | RESOLVED FIXED | ||
| Severity: | wishlist | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Ubuntu | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Patch to download first and last 1 percent of file chunks | ||
|
Description
Byte Smythe
2007-08-27 08:35:45 UTC
Created attachment 21489 [details]
Patch to download first and last 1 percent of file chunks
This is probably a somewhat naive attempt, but I tried it out and, for the size
files I'm downloading, it does what I want. With this in place, I can easily
preview 700 MB files in a short amount of time. Perhaps some tweaking could be
done to allow the user to select the percentage of the end chunks to prioritize
(maybe from 1 to 5 percent).
SVN commit 706964 by guisson:
Prioritise at least 1 % of multimedia files instead of the 1 chunk we currently do.
Initial patch was provided by Byte Smythe with some modifications from myself.
BUG: 149248
M +32 -10 chunkmanager.cpp
--- branches/extragear/kde3/network/ktorrent/libktorrent/torrent/chunkmanager.cpp #706963:706964
@@ -93,22 +93,38 @@
for(Uint32 i=0; i<tor.getNumFiles(); ++i)
{
bt::TorrentFile & file = tor.getFile(i);
- if (file.isMultimedia() && file.getPriority() != bt::ONLY_SEED_PRIORITY)
+ if (!file.isMultimedia() || file.getPriority() == bt::ONLY_SEED_PRIORITY)
+ continue;
+
+ if (file.getFirstChunk() == file.getLastChunk())
{
- prioritise(file.getFirstChunk(), file.getFirstChunk()+1, PREVIEW_PRIORITY);
- if (file.getLastChunk() - file.getFirstChunk() > 2)
- prioritise(file.getLastChunk() -1,file.getLastChunk(), PREVIEW_PRIORITY);
+ // prioritise whole file
+ prioritise(file.getFirstChunk(),file.getLastChunk(),PREVIEW_PRIORITY);
}
+ else
+ {
+ Uint32 chunkOffset;
+ chunkOffset = ((file.getLastChunk() - file.getFirstChunk()) / 100) + 1;
+ prioritise(file.getFirstChunk(), file.getFirstChunk()+chunkOffset, PREVIEW_PRIORITY);
+ if (file.getLastChunk() - file.getFirstChunk() > chunkOffset)
+ {
+ prioritise(file.getLastChunk() - chunkOffset, file.getLastChunk(), PREVIEW_PRIORITY);
+ }
+ }
}
}
else
{
if(tor.isMultimedia())
{
- prioritise(0,1,PREVIEW_PRIORITY);
- if (tor.getNumChunks() > 2)
- prioritise(tor.getNumChunks() - 2,tor.getNumChunks() - 1,PREVIEW_PRIORITY);
- //this->prioritise(getNumChunks()-2, getNumChunks()-1);
+ Uint32 chunkOffset;
+ chunkOffset = (tor.getNumChunks() / 100) + 1;
+
+ prioritise(0,chunkOffset,PREVIEW_PRIORITY);
+ if (tor.getNumChunks() > chunkOffset)
+ {
+ prioritise(tor.getNumChunks() - chunkOffset, tor.getNumChunks() - 1,PREVIEW_PRIORITY);
+ }
}
}
}
@@ -791,9 +807,15 @@
// if it is a multimedia file, prioritise first and last chunks of file
if (tf->isMultimedia())
{
- prioritise(first,first+1,PREVIEW_PRIORITY);
+ Uint32 chunkOffset;
+ chunkOffset = ((last - first) / 100) + 1;
+
+ prioritise(first,first+chunkOffset,PREVIEW_PRIORITY);
if (last - first > 2)
- prioritise(last -1,last, PREVIEW_PRIORITY);
+ {
+ prioritise(last - chunkOffset, last, PREVIEW_PRIORITY);
+ //prioritise(last -1,last, PREVIEW_PRIORITY);
+ }
}
}
else
|