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

def Hellanzb::NZBLeecher::DupeHandler::handleDupeNZBFileNeedsDownload (   nzbFile,
  workingDirDupeMap 
)

Determine whether or not this NZBFile is a known duplicate. If so, also determine if
this NZBFile needs to be downloaded 

Definition at line 185 of file DupeHandler.py.

00185                                                               :
    """ Determine whether or not this NZBFile is a known duplicate. If so, also determine if
    this NZBFile needs to be downloaded """
    isDupe = False
    # Search the dupes on disk for a match
    for file in workingDirDupeMap.iterkeys():
        if nzbFile.subject.find(file) > -1:
            isDupe = True

            debug('handleDupeNeedsDownload: handling dupe: %s' % file)
            # *sigh* we're a dupe. Find the first unidentified index in the dupeEntry
            # (dupeEntry[1] is None)
            for dupeEntry in workingDirDupeMap[file]:
                origin = None
                if dupeEntry[1] is None:
                    # Found an entry -- this is for our specified nzbFile
                    dupeEntry[1] = nzbFile

                    # Set our filename now, since we know it, for sanity sake
                    dupeFilename = nextDupeName(os.path.join(Hellanzb.WORKING_DIR, file),
                                                checkOnDisk = False,
                                                minIteration = dupeEntry[0] + 1)
                    nzbFile.filename = os.path.basename(dupeFilename)
                    debug('handleDupeNeedsDownload: marking fileNum: %i as dupeFilename' \
                          ' %s (dupeEntry index: %i)' % (nzbFile.number, nzbFile.filename,
                                                         dupeEntry[0]))

                    # Now that we have the correct filename we can determine if this dupe
                    # needs to be downloaded
                    if os.path.isfile(dupeFilename):
                        debug('handleDupeNeedsDownload: dupeName: %s needsDownload: False' \
                              % nzbFile.filename)
                        return isDupe, False
                    
                    debug('handleDupeNeedsDownload: dupeName: %s needsDownload: True' \
                          % nzbFile.filename)
                    return isDupe, True

                # Keep track of the origin -- we need to handle it specially (rename it to
                # an actual dupeName ASAP) if there are more duplicates in the NZB than
                # there are currently on disk
                elif dupeEntry[0] == -1:
                    origin = dupeEntry[1]

            # Didn't find a match on disk. Needs to be downloaded
            return isDupe, True
        
    return isDupe, None

"""
Copyright (c) 2005 Philip Jenvey <pjenvey@groovie.org>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. The name of the author or contributors may not be used to endorse or
   promote products derived from this software without specific prior
   written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

$Id: DupeHandler.py 833 2006-09-11 05:34:14Z pjenvey $
"""
"""


Generated by  Doxygen 1.6.0   Back to index