Exemplo n.º 1
0
void QueueCoordinator::SavePartialState()
{
    if (!(g_pOptions->GetServerMode() && g_pOptions->GetSaveQueue() && g_pOptions->GetContinuePartial()))
    {
        return;
    }

    DownloadQueue* pDownloadQueue = DownloadQueue::Lock();

    for (NZBList::iterator it = pDownloadQueue->GetQueue()->begin(); it != pDownloadQueue->GetQueue()->end(); it++)
    {
        NZBInfo* pNZBInfo = *it;
        for (FileList::iterator it2 = pNZBInfo->GetFileList()->begin(); it2 != pNZBInfo->GetFileList()->end(); it2++)
        {
            FileInfo* pFileInfo = *it2;
            if (pFileInfo->GetPartialChanged())
            {
                debug("Saving partial state for %s", pFileInfo->GetFilename());
                g_pDiskState->SaveFileState(pFileInfo, false);
                pFileInfo->SetPartialChanged(false);
            }
        }
    }

    DownloadQueue::Unlock();
}
Exemplo n.º 2
0
void QueueCoordinator::DeleteFileInfo(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, bool bCompleted)
{
    while (g_pArticleCache->FileBusy(pFileInfo))
    {
        usleep(5*1000);
    }

    bool fileDeleted = pFileInfo->GetDeleted();
    pFileInfo->SetDeleted(true);

    StatFileInfo(pFileInfo, bCompleted);

    if (g_pOptions->GetSaveQueue() && g_pOptions->GetServerMode() &&
            (!bCompleted || (pFileInfo->GetMissedArticles() == 0 && pFileInfo->GetFailedArticles() == 0)))
    {
        g_pDiskState->DiscardFile(pFileInfo, true, true, false);
    }

    if (!bCompleted)
    {
        DiscardDiskFile(pFileInfo);
    }

    NZBInfo* pNZBInfo = pFileInfo->GetNZBInfo();

    DownloadQueue::Aspect aspect = { bCompleted && !fileDeleted ?
                                     DownloadQueue::eaFileCompleted : DownloadQueue::eaFileDeleted,
                                     pDownloadQueue, pNZBInfo, pFileInfo
                                   };
    pDownloadQueue->Notify(&aspect);

    // nzb-file could be deleted from queue in "Notify", check if it is still in queue.
    if (std::find(pDownloadQueue->GetQueue()->begin(), pDownloadQueue->GetQueue()->end(), pNZBInfo) !=
            pDownloadQueue->GetQueue()->end())
    {
        pNZBInfo->GetFileList()->Remove(pFileInfo);
        delete pFileInfo;
    }
}
Exemplo n.º 3
0
void HistoryCoordinator::HistoryReturn(DownloadQueue* pDownloadQueue, HistoryList::iterator itHistory, HistoryInfo* pHistoryInfo, bool bReprocess)
{
	char szNiceName[1024];
	pHistoryInfo->GetName(szNiceName, 1024);
	debug("Returning %s from history back to download queue", szNiceName);
	NZBInfo* pNZBInfo = NULL;

	if (bReprocess && pHistoryInfo->GetKind() != HistoryInfo::hkNzb)
	{
		error("Could not restart postprocessing for %s: history item has wrong type", szNiceName);
		return;
	}

	if (pHistoryInfo->GetKind() == HistoryInfo::hkNzb)
	{
		pNZBInfo = pHistoryInfo->GetNZBInfo();

		// unpark files
		bool bUnparked = false;
		for (FileList::iterator it = pNZBInfo->GetFileList()->begin(); it != pNZBInfo->GetFileList()->end(); it++)
		{
			FileInfo* pFileInfo = *it;
			detail("Unpark file %s", pFileInfo->GetFilename());
			bUnparked = true;
		}

		if (!(bUnparked || bReprocess))
		{
			warn("Could not return %s back from history to download queue: history item does not have any files left for download", szNiceName);
			return;
		}

		pDownloadQueue->GetQueue()->push_front(pNZBInfo);
		pHistoryInfo->DiscardNZBInfo();

		// reset postprocessing status variables
		pNZBInfo->SetParCleanup(false);
		if (!pNZBInfo->GetUnpackCleanedUpDisk())
		{
			pNZBInfo->SetUnpackStatus(NZBInfo::usNone);
			pNZBInfo->SetCleanupStatus(NZBInfo::csNone);
			pNZBInfo->SetRenameStatus(NZBInfo::rsNone);
			pNZBInfo->SetPostTotalSec(pNZBInfo->GetPostTotalSec() - pNZBInfo->GetUnpackSec());
			pNZBInfo->SetUnpackSec(0);

			if (ParParser::FindMainPars(pNZBInfo->GetDestDir(), NULL))
			{
				pNZBInfo->SetParStatus(NZBInfo::psNone);
				pNZBInfo->SetPostTotalSec(pNZBInfo->GetPostTotalSec() - pNZBInfo->GetParSec());
				pNZBInfo->SetParSec(0);
				pNZBInfo->SetRepairSec(0);
				pNZBInfo->SetParFull(false);
			}
		}
		pNZBInfo->SetDeleteStatus(NZBInfo::dsNone);
		pNZBInfo->SetDeletePaused(false);
		pNZBInfo->SetMarkStatus(NZBInfo::ksNone);
		pNZBInfo->GetScriptStatuses()->Clear();
		pNZBInfo->SetParkedFileCount(0);
		if (pNZBInfo->GetMoveStatus() == NZBInfo::msFailure)
		{
			pNZBInfo->SetMoveStatus(NZBInfo::msNone);
		}
		pNZBInfo->SetReprocess(bReprocess);
	}

	if (pHistoryInfo->GetKind() == HistoryInfo::hkUrl)
	{
		pNZBInfo = pHistoryInfo->GetNZBInfo();
		pHistoryInfo->DiscardNZBInfo();
		pNZBInfo->SetUrlStatus(NZBInfo::lsNone);
		pNZBInfo->SetDeleteStatus(NZBInfo::dsNone);
		pDownloadQueue->GetQueue()->push_front(pNZBInfo);
	}

	pDownloadQueue->GetHistory()->erase(itHistory);
	// the object "pHistoryInfo" is released few lines later, after the call to "NZBDownloaded"
	pNZBInfo->PrintMessage(Message::mkInfo, "%s returned from history back to download queue", szNiceName);

	if (bReprocess)
	{
		// start postprocessing
		debug("Restarting postprocessing for %s", szNiceName);
		g_pPrePostProcessor->NZBDownloaded(pDownloadQueue, pNZBInfo);
	}

	delete pHistoryInfo;
}
Exemplo n.º 4
0
/*
 * Returns next article for download.
 */
bool QueueCoordinator::GetNextArticle(DownloadQueue* pDownloadQueue, FileInfo* &pFileInfo, ArticleInfo* &pArticleInfo)
{
    // find an unpaused file with the highest priority, then take the next article from the file.
    // if the file doesn't have any articles left for download, we store that fact and search again,
    // ignoring all files which were previously marked as not having any articles.

    // special case: if the file has ExtraPriority-flag set, it has the highest priority and the
    // Paused-flag is ignored.

    //debug("QueueCoordinator::GetNextArticle()");

    bool bOK = false;

    // pCheckedFiles stores
    bool* pCheckedFiles = NULL;
    time_t tCurDate = time(NULL);

    while (!bOK)
    {
        pFileInfo = NULL;
        int iNum = 0;
        int iFileNum = 0;

        for (NZBList::iterator it = pDownloadQueue->GetQueue()->begin(); it != pDownloadQueue->GetQueue()->end(); it++)
        {
            NZBInfo* pNZBInfo = *it;
            for (FileList::iterator it2 = pNZBInfo->GetFileList()->begin(); it2 != pNZBInfo->GetFileList()->end(); it2++)
            {
                FileInfo* pFileInfo1 = *it2;
                if ((!pCheckedFiles || !pCheckedFiles[iNum]) &&
                        !pFileInfo1->GetPaused() && !pFileInfo1->GetDeleted() &&
                        (g_pOptions->GetPropagationDelay() == 0 ||
                         (int)pFileInfo1->GetTime() < (int)tCurDate - g_pOptions->GetPropagationDelay()) &&
                        (!g_pOptions->GetPauseDownload() || pNZBInfo->GetForcePriority()) &&
                        (!pFileInfo ||
                         (pFileInfo1->GetExtraPriority() == pFileInfo->GetExtraPriority() &&
                          pFileInfo1->GetNZBInfo()->GetPriority() > pFileInfo->GetNZBInfo()->GetPriority()) ||
                         (pFileInfo1->GetExtraPriority() > pFileInfo->GetExtraPriority())))
                {
                    pFileInfo = pFileInfo1;
                    iFileNum = iNum;
                }
                iNum++;
            }
        }

        if (!pFileInfo)
        {
            // there are no more files for download
            break;
        }

        if (pFileInfo->GetArticles()->empty() && g_pOptions->GetSaveQueue() && g_pOptions->GetServerMode())
        {
            g_pDiskState->LoadArticles(pFileInfo);
        }

        // check if the file has any articles left for download
        for (FileInfo::Articles::iterator at = pFileInfo->GetArticles()->begin(); at != pFileInfo->GetArticles()->end(); at++)
        {
            pArticleInfo = *at;
            if (pArticleInfo->GetStatus() == ArticleInfo::aiUndefined)
            {
                bOK = true;
                break;
            }
        }

        if (!bOK)
        {
            // the file doesn't have any articles left for download, we mark the file as such
            if (!pCheckedFiles)
            {
                int iTotalFileCount = 0;
                for (NZBList::iterator it = pDownloadQueue->GetQueue()->begin(); it != pDownloadQueue->GetQueue()->end(); it++)
                {
                    NZBInfo* pNZBInfo = *it;
                    iTotalFileCount += pNZBInfo->GetFileList()->size();
                }

                if (iTotalFileCount > 0)
                {
                    int iArrSize = sizeof(bool) * iTotalFileCount;
                    pCheckedFiles = (bool*)malloc(iArrSize);
                    memset(pCheckedFiles, false, iArrSize);
                }
            }
            if (pCheckedFiles)
            {
                pCheckedFiles[iFileNum] = true;
            }
        }
    }

    free(pCheckedFiles);

    return bOK;
}
Exemplo n.º 5
0
void QueueCoordinator::AddNZBFileToQueue(NZBFile* pNZBFile, NZBInfo* pUrlInfo, bool bAddFirst)
{
    debug("Adding NZBFile to queue");

    NZBInfo* pNZBInfo = pNZBFile->GetNZBInfo();

    DownloadQueue* pDownloadQueue = DownloadQueue::Lock();

    DownloadQueue::Aspect foundAspect = { DownloadQueue::eaNzbFound, pDownloadQueue, pNZBInfo, NULL };
    pDownloadQueue->Notify(&foundAspect);

    NZBInfo::EDeleteStatus eDeleteStatus = pNZBInfo->GetDeleteStatus();

    if (eDeleteStatus != NZBInfo::dsNone)
    {
        bool bAllPaused = !pNZBInfo->GetFileList()->empty();
        for (FileList::iterator it = pNZBInfo->GetFileList()->begin(); it != pNZBInfo->GetFileList()->end(); it++)
        {
            FileInfo* pFileInfo = *it;
            bAllPaused &= pFileInfo->GetPaused();
            if (g_pOptions->GetSaveQueue() && g_pOptions->GetServerMode())
            {
                g_pDiskState->DiscardFile(pFileInfo, true, false, false);
            }
        }
        pNZBInfo->SetDeletePaused(bAllPaused);
    }

    if (eDeleteStatus != NZBInfo::dsManual)
    {
        // NZBInfo will be added either to queue or to history as duplicate
        // and therefore can be detached from NZBFile.
        pNZBFile->DetachNZBInfo();
    }

    if (eDeleteStatus == NZBInfo::dsNone)
    {
        if (g_pOptions->GetDupeCheck() && pNZBInfo->GetDupeMode() != dmForce)
        {
            CheckDupeFileInfos(pNZBInfo);
        }

        if (pUrlInfo)
        {
            // insert at the URL position
            for (NZBList::iterator it = pDownloadQueue->GetQueue()->begin(); it != pDownloadQueue->GetQueue()->end(); it++)
            {
                NZBInfo* pPosNzbInfo = *it;
                if (pPosNzbInfo == pUrlInfo)
                {
                    pDownloadQueue->GetQueue()->insert(it, pNZBInfo);
                    break;
                }
            }
        }
        else if (bAddFirst)
        {
            pDownloadQueue->GetQueue()->push_front(pNZBInfo);
        }
        else
        {
            pDownloadQueue->GetQueue()->push_back(pNZBInfo);
        }
    }

    if (pUrlInfo)
    {
        pNZBInfo->SetID(pUrlInfo->GetID());
        pDownloadQueue->GetQueue()->Remove(pUrlInfo);
        delete pUrlInfo;
    }

    if (eDeleteStatus == NZBInfo::dsNone)
    {
        pNZBInfo->PrintMessage(Message::mkInfo, "Collection %s added to queue", pNZBInfo->GetName());
    }

    if (eDeleteStatus != NZBInfo::dsManual)
    {
        DownloadQueue::Aspect addedAspect = { DownloadQueue::eaNzbAdded, pDownloadQueue, pNZBInfo, NULL };
        pDownloadQueue->Notify(&addedAspect);
    }

    pDownloadQueue->Save();

    DownloadQueue::Unlock();
}
Exemplo n.º 6
0
void QueueCoordinator::Load()
{
    DownloadQueue* pDownloadQueue = DownloadQueue::Lock();

    bool bStatLoaded = true;
    bool bPerfectServerMatch = true;
    bool bQueueLoaded = false;

    if (g_pOptions->GetServerMode() && g_pOptions->GetSaveQueue())
    {
        bStatLoaded = g_pStatMeter->Load(&bPerfectServerMatch);

        if (g_pOptions->GetReloadQueue() && g_pDiskState->DownloadQueueExists())
        {
            bQueueLoaded = g_pDiskState->LoadDownloadQueue(pDownloadQueue, g_pServerPool->GetServers());
        }
        else
        {
            g_pDiskState->DiscardDownloadQueue();
        }
    }

    if (bQueueLoaded && bStatLoaded)
    {
        g_pDiskState->CleanupTempDir(pDownloadQueue);
    }

    if (bQueueLoaded && bStatLoaded && !bPerfectServerMatch)
    {
        debug("Changes in section <NEWS SERVERS> of config file detected, resaving queue");

        // re-save current server list into diskstate to update server ids
        g_pStatMeter->Save();

        // re-save queue into diskstate to update server ids
        pDownloadQueue->Save();

        // re-save file states into diskstate to update server ids
        if (g_pOptions->GetServerMode() && g_pOptions->GetSaveQueue())
        {
            for (NZBList::iterator it = pDownloadQueue->GetQueue()->begin(); it != pDownloadQueue->GetQueue()->end(); it++)
            {
                NZBInfo* pNZBInfo = *it;

                if (g_pOptions->GetContinuePartial())
                {
                    for (FileList::iterator it2 = pNZBInfo->GetFileList()->begin(); it2 != pNZBInfo->GetFileList()->end(); it2++)
                    {
                        FileInfo* pFileInfo = *it2;
                        if (!pFileInfo->GetArticles()->empty())
                        {
                            g_pDiskState->SaveFileState(pFileInfo, false);
                        }
                    }
                }

                for (CompletedFiles::iterator it2 = pNZBInfo->GetCompletedFiles()->begin(); it2 != pNZBInfo->GetCompletedFiles()->end(); it2++)
                {
                    CompletedFile* pCompletedFile = *it2;
                    if (pCompletedFile->GetStatus() != CompletedFile::cfSuccess && pCompletedFile->GetID() > 0)
                    {
                        FileInfo* pFileInfo = new FileInfo(pCompletedFile->GetID());
                        if (g_pDiskState->LoadFileState(pFileInfo, g_pServerPool->GetServers(), false))
                        {
                            g_pDiskState->SaveFileState(pFileInfo, true);
                        }
                        delete pFileInfo;
                    }
                }
            }
        }
    }

    CoordinatorDownloadQueue::Loaded();
    DownloadQueue::Unlock();
}
Exemplo n.º 7
0
/*
 * Creates new nzb-item out of existing files from other nzb-items.
 * If any of file-items is being downloaded the command fail.
 * For each file-item an event "eaFileDeleted" is fired.
 */
bool QueueCoordinator::SplitQueueEntries(DownloadQueue* pDownloadQueue, FileList* pFileList, const char* szName, NZBInfo** pNewNZBInfo)
{
    if (pFileList->empty())
    {
        return false;
    }

    NZBInfo* pSrcNZBInfo = NULL;

    for (FileList::iterator it = pFileList->begin(); it != pFileList->end(); it++)
    {
        FileInfo* pFileInfo = *it;
        if (pFileInfo->GetActiveDownloads() > 0 || pFileInfo->GetCompletedArticles() > 0)
        {
            error("Could not split %s. File is already (partially) downloaded", pFileInfo->GetFilename());
            return false;
        }
        if (pFileInfo->GetNZBInfo()->GetPostInfo())
        {
            error("Could not split %s. File in post-process-stage", pFileInfo->GetFilename());
            return false;
        }
        if (!pSrcNZBInfo)
        {
            pSrcNZBInfo = pFileInfo->GetNZBInfo();
        }
    }

    NZBInfo* pNZBInfo = new NZBInfo();
    pDownloadQueue->GetQueue()->push_back(pNZBInfo);

    pNZBInfo->SetFilename(pSrcNZBInfo->GetFilename());
    pNZBInfo->SetName(szName);
    pNZBInfo->SetCategory(pSrcNZBInfo->GetCategory());
    pNZBInfo->SetFullContentHash(0);
    pNZBInfo->SetFilteredContentHash(0);
    pNZBInfo->SetPriority(pSrcNZBInfo->GetPriority());
    pNZBInfo->BuildDestDirName();
    pNZBInfo->SetQueuedFilename(pSrcNZBInfo->GetQueuedFilename());
    pNZBInfo->GetParameters()->CopyFrom(pSrcNZBInfo->GetParameters());

    pSrcNZBInfo->SetFullContentHash(0);
    pSrcNZBInfo->SetFilteredContentHash(0);

    for (FileList::iterator it = pFileList->begin(); it != pFileList->end(); it++)
    {
        FileInfo* pFileInfo = *it;

        DownloadQueue::Aspect aspect = { DownloadQueue::eaFileDeleted, pDownloadQueue, pFileInfo->GetNZBInfo(), pFileInfo };
        pDownloadQueue->Notify(&aspect);

        pFileInfo->SetNZBInfo(pNZBInfo);
        pNZBInfo->GetFileList()->push_back(pFileInfo);
        pSrcNZBInfo->GetFileList()->Remove(pFileInfo);

        pSrcNZBInfo->SetFileCount(pSrcNZBInfo->GetFileCount() - 1);
        pSrcNZBInfo->SetSize(pSrcNZBInfo->GetSize() - pFileInfo->GetSize());
        pSrcNZBInfo->SetRemainingSize(pSrcNZBInfo->GetRemainingSize() - pFileInfo->GetRemainingSize());
        pSrcNZBInfo->SetCurrentSuccessSize(pSrcNZBInfo->GetCurrentSuccessSize() - pFileInfo->GetSuccessSize());
        pSrcNZBInfo->SetCurrentFailedSize(pSrcNZBInfo->GetCurrentFailedSize() - pFileInfo->GetFailedSize() - pFileInfo->GetMissedSize());
        pSrcNZBInfo->SetTotalArticles(pSrcNZBInfo->GetTotalArticles() - pFileInfo->GetTotalArticles());
        pSrcNZBInfo->SetCurrentSuccessArticles(pSrcNZBInfo->GetCurrentSuccessArticles() - pFileInfo->GetSuccessArticles());
        pSrcNZBInfo->SetCurrentFailedArticles(pSrcNZBInfo->GetCurrentFailedArticles() - pFileInfo->GetFailedArticles());
        pSrcNZBInfo->GetCurrentServerStats()->ListOp(pFileInfo->GetServerStats(), ServerStatList::soSubtract);

        pNZBInfo->SetFileCount(pNZBInfo->GetFileCount() + 1);
        pNZBInfo->SetSize(pNZBInfo->GetSize() + pFileInfo->GetSize());
        pNZBInfo->SetRemainingSize(pNZBInfo->GetRemainingSize() + pFileInfo->GetRemainingSize());
        pNZBInfo->SetCurrentSuccessSize(pNZBInfo->GetCurrentSuccessSize() + pFileInfo->GetSuccessSize());
        pNZBInfo->SetCurrentFailedSize(pNZBInfo->GetCurrentFailedSize() + pFileInfo->GetFailedSize() + pFileInfo->GetMissedSize());
        pNZBInfo->SetTotalArticles(pNZBInfo->GetTotalArticles() + pFileInfo->GetTotalArticles());
        pNZBInfo->SetCurrentSuccessArticles(pNZBInfo->GetCurrentSuccessArticles() + pFileInfo->GetSuccessArticles());
        pNZBInfo->SetCurrentFailedArticles(pNZBInfo->GetCurrentFailedArticles() + pFileInfo->GetFailedArticles());
        pNZBInfo->GetCurrentServerStats()->ListOp(pFileInfo->GetServerStats(), ServerStatList::soAdd);

        if (pFileInfo->GetParFile())
        {
            pSrcNZBInfo->SetParSize(pSrcNZBInfo->GetParSize() - pFileInfo->GetSize());
            pSrcNZBInfo->SetParCurrentSuccessSize(pSrcNZBInfo->GetParCurrentSuccessSize() - pFileInfo->GetSuccessSize());
            pSrcNZBInfo->SetParCurrentFailedSize(pSrcNZBInfo->GetParCurrentFailedSize() - pFileInfo->GetFailedSize() - pFileInfo->GetMissedSize());
            pSrcNZBInfo->SetRemainingParCount(pSrcNZBInfo->GetRemainingParCount() - 1);

            pNZBInfo->SetParSize(pNZBInfo->GetParSize() + pFileInfo->GetSize());
            pNZBInfo->SetParCurrentSuccessSize(pNZBInfo->GetParCurrentSuccessSize() + pFileInfo->GetSuccessSize());
            pNZBInfo->SetParCurrentFailedSize(pNZBInfo->GetParCurrentFailedSize() + pFileInfo->GetFailedSize() + pFileInfo->GetMissedSize());
            pNZBInfo->SetRemainingParCount(pNZBInfo->GetRemainingParCount() + 1);
        }

        if (pFileInfo->GetPaused())
        {
            pSrcNZBInfo->SetPausedFileCount(pSrcNZBInfo->GetPausedFileCount() - 1);
            pSrcNZBInfo->SetPausedSize(pSrcNZBInfo->GetPausedSize() - pFileInfo->GetRemainingSize());

            pNZBInfo->SetPausedFileCount(pSrcNZBInfo->GetPausedFileCount() + 1);
            pNZBInfo->SetPausedSize(pNZBInfo->GetPausedSize() + pFileInfo->GetRemainingSize());
        }
    }

    pNZBInfo->UpdateMinMaxTime();
    if (pSrcNZBInfo->GetCompletedFiles()->empty())
    {
        pSrcNZBInfo->UpdateMinMaxTime();
    }

    if (pSrcNZBInfo->GetFileList()->empty())
    {
        pDownloadQueue->GetQueue()->Remove(pSrcNZBInfo);
        g_pDiskState->DiscardFiles(pSrcNZBInfo);
        delete pSrcNZBInfo;
    }

    *pNewNZBInfo = pNZBInfo;
    return true;
}
Exemplo n.º 8
0
bool Scanner::AddFileToQueue(const char* szFilename, const char* szNZBName, const char* szCategory,
	int iPriority, const char* szDupeKey, int iDupeScore, EDupeMode eDupeMode,
	NZBParameterList* pParameters, bool bAddTop, bool bAddPaused, NZBInfo* pUrlInfo, int* pNZBID)
{
	const char* szBasename = Util::BaseFileName(szFilename);

	info("Adding collection %s to queue", szBasename);

	NZBFile* pNZBFile = NZBFile::Create(szFilename, szCategory);
	bool bOK = pNZBFile != NULL;
	if (!bOK)
	{
		error("Could not add collection %s to queue", szBasename);
	}

	char bakname2[1024];
	if (!Util::RenameBak(szFilename, pNZBFile ? "queued" : "error", false, bakname2, 1024))
	{
		bOK = false;
		char szSysErrStr[256];
		error("Could not rename file %s to %s: %s", szFilename, bakname2, Util::GetLastErrorMessage(szSysErrStr, sizeof(szSysErrStr)));
	}

	if (bOK)
	{
		NZBInfo* pNZBInfo = pNZBFile->GetNZBInfo();
		pNZBInfo->SetQueuedFilename(bakname2);

		if (szNZBName && strlen(szNZBName) > 0)
		{
			pNZBInfo->SetName(NULL);
#ifdef WIN32
			char* szAnsiFilename = strdup(szNZBName);
			WebUtil::Utf8ToAnsi(szAnsiFilename, strlen(szAnsiFilename) + 1);
			pNZBInfo->SetFilename(szAnsiFilename);
			free(szAnsiFilename);
#else
			pNZBInfo->SetFilename(szNZBName);
#endif
			pNZBInfo->BuildDestDirName();
		}

		pNZBInfo->SetDupeKey(szDupeKey);
		pNZBInfo->SetDupeScore(iDupeScore);
		pNZBInfo->SetDupeMode(eDupeMode);
		pNZBInfo->SetPriority(iPriority);
		if (pUrlInfo)
		{
			pNZBInfo->SetURL(pUrlInfo->GetURL());
			pNZBInfo->SetUrlStatus(pUrlInfo->GetUrlStatus());
		}

		if (pNZBFile->GetPassword())
		{
			pNZBInfo->GetParameters()->SetParameter("*Unpack:Password", pNZBFile->GetPassword());
		}

		pNZBInfo->GetParameters()->CopyFrom(pParameters);

		for (::FileList::iterator it = pNZBInfo->GetFileList()->begin(); it != pNZBInfo->GetFileList()->end(); it++)
		{
			FileInfo* pFileInfo = *it;
			pFileInfo->SetPaused(bAddPaused);
		}

		g_pQueueCoordinator->AddNZBFileToQueue(pNZBFile, pUrlInfo, bAddTop);

		if (pNZBID)
		{
			*pNZBID = pNZBInfo->GetID();
		}
	}

	delete pNZBFile;

	return bOK;
}