Skip to content

Commit fe31a32

Browse files
authored
* prevent crash when file can not be unlinked (#275)
1 parent 4e787fb commit fe31a32

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

daily-rotate-file.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,16 @@ var DailyRotateFile = function (options) {
105105
if (options.zippedArchive) {
106106
var gzName = params.name + '.gz';
107107
if (fs.existsSync(gzName)) {
108-
fs.unlinkSync(gzName);
108+
try {
109+
fs.unlinkSync(gzName);
110+
}
111+
catch (_err) {
112+
// file is there but we got an error when trying to delete,
113+
// so permissions problem or concurrency issue and another
114+
// process already deleted it we could detect the concurrency
115+
// issue by checking err.type === ENOENT or EACCESS for
116+
// permissions ... but then?
117+
}
109118
self.emit('logRemoved', gzName);
110119
return;
111120
}

0 commit comments

Comments
 (0)