Downloads are not possible to resume if the queue is lost since segmented downloads introduced

Bug #312946 reported by eMTee
2
Affects Status Importance Assigned to Milestone
DC++
Fix Released
Undecided
Unassigned

Bug Description

...so here's a function for recheck the temporary files' integrity and rebuild the queue item's segments thus it makes possible to resume downloads when the queue item is lost. The idea came from uTorrent's similar function and I used the dropped Advanced resume by tth algorythm as a base.
This is a suprisingly frequent problem and support questions about a solution can be found either in DC++'s or other mods' forums.
The patch introduces a menu function called Recheck integrity for the files stored in the queue. If the queue is lost or damaged the user re-adds the same files to the queue and then he/she will be able to recheck the integrity of the files. As the queue item's segmentset will be rebuilt the download can be resumed from where it stopped.
The function also useful for salvage the blocks remain intact in the rare case when the tempfile is damaged somehow. Also it may helps the user in a common case when the tempfile stucks in the unfinished folder because of move problems at the time the file is finished. If recheck results 100% finished file then it will try the move operation again.
The initial version of the patch contained code for disconnect all running downloads before the start of the recheck operation, however, because I was unable to find a reliable way to wait until all running segments finished this part was removed. In the attached patch the opreration starts only if the queue item is not running.

Thanks poy for help optimize the code and the functionality of this patch.

Tags: rechek resume
Revision history for this message
eMTee (realprogger) wrote :
Revision history for this message
poy (poy) wrote :

recheck4.patch - nearly the same as eMTee's recheck3.patch but in a threaded way, so that the GUI doesn't freeze while rechecking.
event added in QueueManagerListener to propagate results of the recheck operation to the GUI.
not tested.

Revision history for this message
poy (poy) wrote :

recheck5.patch solves the issue of a user who would have the clever idea of removing an item from the queue while it's being rechecked...

Revision history for this message
Jacek Sieka (arnetheduck) wrote :

nice but...

there's a race condition with remove before recheck has been set to true but after it's been started...also, this should probably be a flag on the queue item, not a bool.

also, outside the qm cs the queueitem may become invalid (no queueitem members may be accessed outside locks)

the rechecked event should not send a string but a status (starting, done) so the gui can choose what to do (display string, disable menu options, whatever).

also, it seems that if the file is being rechecked, connections will be dropped and not rerequested when checking finishes (if the file is the only file from a specific user)

something like this should probably be done when adding a file when the target already exists (to scavenge the finished bits), would be nice for file repair...although I'm not sure what should happen with the original file (move to temp location, copy to temp location and remove when download is done, etc)

Revision history for this message
poy (poy) wrote :

recheck6.patch to solve critical sections issues: while the rechecker reads the file, it stores good segments it finds in an array; when it's done, it sees if the QueueItem pointer can still be found and locks and adds stored segments to it.

Revision history for this message
poy (poy) wrote :
Revision history for this message
poy (poy) wrote :

reworked events.

poy (poy)
Changed in dcplusplus:
status: New → Fix Committed
eMTee (realprogger)
Changed in dcplusplus:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.