Comparing version 1.0.27 to 1.0.28
@@ -196,17 +196,38 @@ /* | ||
} | ||
function fsCheckStats (fileName, cbf) | ||
{ | ||
fs.exists (fileName, function (exists) { | ||
if (exists) | ||
{ | ||
fs.stat (fileName, function (err, stats) { | ||
cbf (err, stats) | ||
}) | ||
} else { | ||
cbf (new Error ('File not exisits:' + fileName)) | ||
} | ||
}) | ||
} | ||
function checkMaxDbSize () { | ||
if (fs.existsSync(getFileNameForDb()) && fs.statSync(getFileNameForDb()).size >= (config.maxDbSize || 1024 * 1024 * 50)) { | ||
db.remove({ts: {$lt: new Date().getTime() - (1000 * 60 * 60)}}, function (err, numRemoved) { | ||
try { | ||
if (err) | ||
{ | ||
logger.error('checkMaxDbSize: removing old records from NeDB failed: %s', (err.msg||err.toString())) | ||
} else { | ||
logger.info ('checkMaxDbSize: maximum reached %d records deleted', numRemoved||0) | ||
} | ||
} catch (error) { | ||
logger.error ('checkMaxDbSize: Unknown error:' + error, {error: error, dbError: err||'-', numRemoved: numRemoved||-1}) | ||
} | ||
}) | ||
} | ||
fsCheckStats (getFileNameForDb(), function (err, fsStat) { | ||
if (!err) | ||
{ | ||
if (fsStat.size >= 0 )// (config.maxDbSize || 1024 * 1024 * 50)) | ||
{ | ||
db.remove({ts: {$lt: new Date().getTime() - (1000 * 60 * 60)}}, function (err, numRemoved) { | ||
try { | ||
if (err) | ||
{ | ||
logger.error('checkMaxDbSize: removing old records from NeDB failed: %s', (err.msg||err.toString())) | ||
} else { | ||
logger.info ('checkMaxDbSize: maximum reached %d records deleted', numRemoved||0) | ||
} | ||
} catch (error) { | ||
logger.error ('checkMaxDbSize: Unknown error:' + error, {error: error, dbError: err||'-', numRemoved: numRemoved||-1}) | ||
} | ||
}) | ||
} | ||
} | ||
}) | ||
} | ||
@@ -213,0 +234,0 @@ SpmSender.prototype.sendErrorHandler = function (err) { |
{ | ||
"name": "spm-agent", | ||
"version": "1.0.27", | ||
"version": "1.0.28", | ||
"description": "Node.js agent framework for SPM by Sematext", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89232
23
796