mirror of
https://github.com/nzbget/nzbget.git
synced 2026-01-22 12:57:53 -05:00
When an nzb-file isn’t added to queue for some reason, the file is now also added to history (in addition to messages printed to log): - for malformed nzb-files which cannot be parsed the status in history “DELETE: SCAN”; - for duplicate files with exactly same content status “DELETE: COPY”; - for duplicate files having history items with status “GOOD” - status “DELETE: GOOD”; - for duplicate files having history items with status “SUCCESS” - status “DELETE: SUCCESS”; - history items have log-entries with explanation; - new values for field “DeleteStatus” of RPC-Method “history”: GOOD, SUCCESS, COPY, SCAN; - new values for field “Status” of RPC-Method “history”: "FAILURE/SCAN”, ”DELETED/COPY”, "DELETED/GOOD”, "DELETED/SUCCESS”; - one exception: for files added from RSS-feeds no history items are created, the files are ignored as if they were filtered.
85 lines
2.3 KiB
C++
85 lines
2.3 KiB
C++
/*
|
|
* This file is part of nzbget
|
|
*
|
|
* Copyright (C) 2015 Andrey Prygunkov <hugbug@users.sourceforge.net>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* $Revision$
|
|
* $Date$
|
|
*
|
|
*/
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#ifdef WIN32
|
|
#include "win32.h"
|
|
#endif
|
|
|
|
#include "catch.h"
|
|
|
|
#include "nzbget.h"
|
|
#include "NZBFile.h"
|
|
#include "Options.h"
|
|
#include "TestUtil.h"
|
|
|
|
void TestNzb(std::string TestFilename)
|
|
{
|
|
INFO(std::string("Filename: ") + TestFilename);
|
|
|
|
std::string NzbFilename(TestUtil::TestDataDir() + "/nzbfile/"+ TestFilename + ".nzb");
|
|
std::string InfoFilename(TestUtil::TestDataDir() + "/nzbfile/"+ TestFilename + ".txt");
|
|
|
|
NZBFile* pNZBFile = new NZBFile(NzbFilename.c_str(), "");
|
|
bool bParsedOK = pNZBFile->Parse();
|
|
REQUIRE(bParsedOK == true);
|
|
|
|
FILE* infofile = fopen(InfoFilename.c_str(), FOPEN_RB);
|
|
REQUIRE(infofile != NULL);
|
|
char buffer[1024];
|
|
|
|
while (fgets(buffer, sizeof(buffer), infofile) && *buffer == '#') ;
|
|
REQUIRE(*buffer);
|
|
|
|
int iFileCount = atoi(buffer);
|
|
REQUIRE(pNZBFile->GetNZBInfo()->GetFileCount() == iFileCount);
|
|
|
|
for (int i = 0; i < iFileCount; i++)
|
|
{
|
|
while (fgets(buffer, sizeof(buffer), infofile) && *buffer == '#') ;
|
|
REQUIRE(*buffer);
|
|
FileInfo* pFileInfo = pNZBFile->GetNZBInfo()->GetFileList()->at(i);
|
|
REQUIRE(pFileInfo != NULL);
|
|
Util::TrimRight(buffer);
|
|
REQUIRE(std::string(pFileInfo->GetFilename()) == std::string(buffer));
|
|
}
|
|
|
|
fclose(infofile);
|
|
delete pNZBFile;
|
|
}
|
|
|
|
TEST_CASE("Nzb parser", "[NZBFile][TestData]")
|
|
{
|
|
Options::CmdOptList cmdOpts;
|
|
cmdOpts.push_back("SaveQueue=no");
|
|
Options options(&cmdOpts, NULL);
|
|
|
|
TestNzb("dotless");
|
|
TestNzb("plain");
|
|
}
|