-
Notifications
You must be signed in to change notification settings - Fork 25
Description
I meet the problem: the first log is always deleted when sizerollingfile tree is used. I dig the problem.
The problem code
void detectFileIndex() { var rootDir = Directory(filenamePrefix); <<== this is wrong, because it is not directory, it is prefix patten. if (!rootDir.existsSync()) { /// no files created yet. _fileIndex = 0; rollToNextFile(); return; } if (filenamePrefix.contains(Platform.pathSeparator)) { rootDir = Directory(filenamePrefix.substring( 0, filenamePrefix.lastIndexOf(Platform.pathSeparator))); } var logListIndexes = rootDir .listSync() .map((fe) => getLogIndex(fe.path)) .where((i) => i >= 0) .toList(); logListIndexes.sort();
I try to fix it.
` void detectFileIndex() {
var rootDir;
if (filenamePrefix.contains(Platform.pathSeparator)) { <<== changed
} else {
rootDir = Directory(filenamePrefix);
if (!rootDir.existsSync()) {
/// no files created yet.
_fileIndex = 0;
rollToNextFile();
return;
}
}
rootDir = Directory(filenamePrefix.substring(
0, filenamePrefix.lastIndexOf(Platform.pathSeparator)));
var logListIndexes = rootDir
.listSync()
.map((fe) => getLogIndex(fe.path))
.where((i) => (i >= 0) as bool) <<==changed, otherwise the runtime exception happen,
.toList();
logListIndexes.sort();
`
After the fix, it seems to work as expected.
Could you review and make update?