Logo Search packages:      
Sourcecode: hellanzb version File versions  Download package

def Hellanzb::NZBQueue::ensureSafePostponedLoad (   nzbFileName  ) 

Force doesn't immediately abort the download of the forced out NZB -- it lets the
NZBLeechers currently working on them finish. We need to be careful of forced NZBs
that are so small, that they finish downloading before these 'slower' NZBLeechers are
even done with the previous, forced out NZB. The parseNZB function could end up
colliding with the leechers, while parseNZB looks for segments on disk/to be skipped

Definition at line 399 of file NZBQueue.py.

00399                                         :
    """ Force doesn't immediately abort the download of the forced out NZB -- it lets the
    NZBLeechers currently working on them finish. We need to be careful of forced NZBs
    that are so small, that they finish downloading before these 'slower' NZBLeechers are
    even done with the previous, forced out NZB. The parseNZB function could end up
    colliding with the leechers, while parseNZB looks for segments on disk/to be skipped
    """
    # Look for any NZBLeechers downloading files for the specified unpostponed NZB. They
    # are most likely left over from a force call, using a very small NZB.
    shouldCancel = False
    cancelledClients = []
    for nsf in Hellanzb.nsfs:
        for nzbl in nsf.clients:
            if nzbl.currentSegment != None and \
                    os.path.basename(nzbl.currentSegment.nzbFile.nzb.nzbFileName) == \
                    os.path.basename(nzbFileName):
                # the easiest way to prevent weird things from happening (such as the
                # parser getting confused about what needs to be downloaded/skipped) is to
                # just pull the trigger on those slow NZBLeechers connections --
                # disconnect them and ensure the segments they were trying to download
                # aren't requeued
                debug('%s Aborting/Disconnecting to ensure safe postponed NZB load' % str(nzbl))
                shouldCancel = True
                nzbl.currentSegment.dontRequeue = True
                cancelledClients.append(nzbl)

                # Can't recall the details of why we should manually loseConnection(), do
                # isLoggedIn and also deactivate() below -- but this is was
                # cancelCurrent() does
                nzbl.transport.loseConnection()
                nzbl.isLoggedIn = False
                
                if nzbl.currentSegment is not None and \
                        nzbl.currentSegment.encodedData is not None:
                    try:
                        name = nzbl.currentSegment.getTempFileName() + '_ENC'
                        debug('%s Closing encodedData file: %s' % (str(nzbl), name))
                        nzbl.currentSegment.encodedData.close()
                        debug('%s Closed encodedData file' % str(nzbl))
                    except Exception, e:
                        debug('%s Error while closing encodedData file' % str(nzbl), e)
                        pass

    if shouldCancel:
        # Also reset the state of the queue if we had to do any cleanup
        Hellanzb.queue.cancel()

        for nzbl in cancelledClients:
            nzbl.deactivate()
        
def findAndLoadPostponedDir(nzb):


Generated by  Doxygen 1.6.0   Back to index