mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 10:32:56 +01:00
[SF 2632636] FileChannel Purge Unit Tests Broken
This commit is contained in:
@@ -302,8 +302,14 @@ void FileChannel::setCompress(const std::string& compress)
|
||||
|
||||
void FileChannel::setPurgeAge(const std::string& age)
|
||||
{
|
||||
delete _pPurgeStrategy;
|
||||
_pPurgeStrategy = 0;
|
||||
_purgeAge = "none";
|
||||
if (age.empty() || 0 == icompare(age, "none")) return;
|
||||
|
||||
std::string::const_iterator it = age.begin();
|
||||
std::string::const_iterator end = age.end();
|
||||
|
||||
int n = 0;
|
||||
while (it != end && std::isspace(*it)) ++it;
|
||||
while (it != end && std::isdigit(*it)) { n *= 10; n += *it++ - '0'; }
|
||||
@@ -324,8 +330,10 @@ void FileChannel::setPurgeAge(const std::string& age)
|
||||
factor = 30*Timespan::DAYS;
|
||||
else if (unit != "seconds")
|
||||
throw InvalidArgumentException("purgeAge", age);
|
||||
|
||||
delete _pPurgeStrategy;
|
||||
|
||||
if (0 == n)
|
||||
throw InvalidArgumentException("Zero is not valid purge age.");
|
||||
|
||||
_pPurgeStrategy = new PurgeByAgeStrategy(Timespan(factor*n));
|
||||
_purgeAge = age;
|
||||
}
|
||||
@@ -333,14 +341,22 @@ void FileChannel::setPurgeAge(const std::string& age)
|
||||
|
||||
void FileChannel::setPurgeCount(const std::string& count)
|
||||
{
|
||||
delete _pPurgeStrategy;
|
||||
_pPurgeStrategy = 0;
|
||||
_purgeAge = "none";
|
||||
if (count.empty() || 0 == icompare(count, "none")) return;
|
||||
|
||||
int n = 0;
|
||||
std::string::const_iterator it = count.begin();
|
||||
std::string::const_iterator end = count.end();
|
||||
int n = 0;
|
||||
|
||||
while (it != end && std::isspace(*it)) ++it;
|
||||
while (it != end && std::isdigit(*it)) { n *= 10; n += *it++ - '0'; }
|
||||
while (it != end && std::isspace(*it)) ++it;
|
||||
|
||||
delete _pPurgeStrategy;
|
||||
if (0 == n)
|
||||
throw InvalidArgumentException("Zero is not valid purge count.");
|
||||
|
||||
_pPurgeStrategy = new PurgeByCountStrategy(n);
|
||||
_purgeCount = count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user