summaryrefslogtreecommitdiff
path: root/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-07 13:12:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 10:02:59 +0000
commit33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (patch)
treef6af110909c79b2759136554f1143d8b0572af0a /chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib
parent7d2c5d177e9813077a621df8d18c0deda73099b3 (diff)
downloadqtwebengine-chromium-33fc33aa94d4add0878ec30dc818e34e1dd3cc2a.tar.gz
BASELINE: Update Chromium to 104.0.5112.120
Change-Id: I5d2726c2ab018d75d055739b6ba64317904f05bb Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438935 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib')
-rw-r--r--chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/DateRollingFileStream.js20
-rw-r--r--chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileStream.js10
-rw-r--r--chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileWriteStream.js76
-rw-r--r--chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameFormatter.js6
-rw-r--r--chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameParser.js5
-rw-r--r--chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/moveAndMaybeCompressFile.js29
6 files changed, 117 insertions, 29 deletions
diff --git a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/DateRollingFileStream.js b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/DateRollingFileStream.js
index 9bf52f741b0..ea7209ae8d2 100644
--- a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/DateRollingFileStream.js
+++ b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/DateRollingFileStream.js
@@ -13,13 +13,21 @@ class DateRollingFileStream extends RollingFileWriteStream {
if (!pattern) {
pattern = 'yyyy-MM-dd';
}
- if (options.daysToKeep) {
- options.numToKeep = options.daysToKeep;
- }
- if (pattern.startsWith('.')) {
- pattern = pattern.substring(1);
- }
options.pattern = pattern;
+ if (!options.numBackups && options.numBackups !== 0) {
+ if (!options.daysToKeep && options.daysToKeep !== 0) {
+ options.daysToKeep = 1;
+ } else {
+ process.emitWarning(
+ "options.daysToKeep is deprecated due to the confusion it causes when used " +
+ "together with file size rolling. Please use options.numBackups instead.",
+ "DeprecationWarning", "streamroller-DEP0001"
+ );
+ }
+ options.numBackups = options.daysToKeep;
+ } else {
+ options.daysToKeep = options.numBackups;
+ }
super(filename, options);
this.mode = this.options.mode;
}
diff --git a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileStream.js b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileStream.js
index ec794c33cea..7e01c0c847a 100644
--- a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileStream.js
+++ b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileStream.js
@@ -9,12 +9,14 @@ class RollingFileStream extends RollingFileWriteStream {
if (size) {
options.maxSize = size;
}
- if (!backups) {
- backups = 1;
+ if (!options.numBackups && options.numBackups !== 0) {
+ if (!backups && backups !== 0) {
+ backups = 1;
+ }
+ options.numBackups = backups;
}
- options.numToKeep = backups;
super(filename, options);
- this.backups = this.options.numToKeep;
+ this.backups = options.numBackups;
this.size = this.options.maxSize;
}
diff --git a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileWriteStream.js b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileWriteStream.js
index 34e60e4e887..47b123265f0 100644
--- a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileWriteStream.js
+++ b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/RollingFileWriteStream.js
@@ -1,5 +1,11 @@
const debug = require("debug")("streamroller:RollingFileWriteStream");
-const fs = require("fs-extra");
+
+const realFs = require('fs');
+const current = realFs.realpath.native;
+if (!realFs.realpath.native) realFs.realpath.native = realFs.realpath;
+const fs = require('fs-extra');
+realFs.realpath.native = current;
+
const path = require("path");
const newNow = require("./now");
const format = require("date-format");
@@ -21,7 +27,7 @@ class RollingFileWriteStream extends Writable {
* @param {number} options.numToKeep - The max numbers of files to keep.
* @param {number} options.maxSize - The maxSize one file can reach. Unit is Byte.
* This should be more than 1024. The default is Number.MAX_SAFE_INTEGER.
- * @param {string} options.mode - The mode of the files. The default is '0644'. Refer to stream.writable for more.
+ * @param {string} options.mode - The mode of the files. The default is '0600'. Refer to stream.writable for more.
* @param {string} options.flags - The default is 'a'. Refer to stream.flags for more.
* @param {boolean} options.compress - Whether to compress backup files.
* @param {boolean} options.keepFileExt - Whether to keep the file extension.
@@ -30,6 +36,9 @@ class RollingFileWriteStream extends Writable {
*/
constructor(filePath, options) {
debug(`constructor: creating RollingFileWriteStream. path=${filePath}`);
+ if (typeof filePath !== "string" || filePath.length === 0) {
+ throw new Error(`Invalid filename: ${filePath}`);
+ }
super(options);
this.options = this._parseOption(options);
this.fileObject = path.parse(filePath);
@@ -41,13 +50,15 @@ class RollingFileWriteStream extends Writable {
alwaysIncludeDate: this.options.alwaysIncludePattern,
needsIndex: this.options.maxSize < Number.MAX_SAFE_INTEGER,
compress: this.options.compress,
- keepFileExt: this.options.keepFileExt
+ keepFileExt: this.options.keepFileExt,
+ fileNameSep: this.options.fileNameSep
});
this.fileNameParser = fileNameParser({
file: this.fileObject,
keepFileExt: this.options.keepFileExt,
- pattern: this.options.pattern
+ pattern: this.options.pattern,
+ fileNameSep: this.options.fileNameSep
});
this.state = {
@@ -92,7 +103,7 @@ class RollingFileWriteStream extends Writable {
maxSize: Number.MAX_SAFE_INTEGER,
numToKeep: Number.MAX_SAFE_INTEGER,
encoding: "utf8",
- mode: parseInt("0644", 8),
+ mode: parseInt("0600", 8),
flags: "a",
compress: false,
keepFileExt: false,
@@ -102,7 +113,17 @@ class RollingFileWriteStream extends Writable {
if (options.maxSize <= 0) {
throw new Error(`options.maxSize (${options.maxSize}) should be > 0`);
}
- if (options.numToKeep <= 0) {
+ // options.numBackups will supercede options.numToKeep
+ if (options.numBackups || options.numBackups === 0) {
+ if (options.numBackups < 0) {
+ throw new Error(`options.numBackups (${options.numBackups}) should be >= 0`);
+ } else if (options.numBackups >= Number.MAX_SAFE_INTEGER) {
+ // to cater for numToKeep (include the hot file) at Number.MAX_SAFE_INTEGER
+ throw new Error(`options.numBackups (${options.numBackups}) should be < Number.MAX_SAFE_INTEGER`);
+ } else {
+ options.numToKeep = options.numBackups + 1;
+ }
+ } else if (options.numToKeep <= 0) {
throw new Error(`options.numToKeep (${options.numToKeep}) should be > 0`);
}
debug(
@@ -177,10 +198,14 @@ class RollingFileWriteStream extends Writable {
index: i + 1
});
+ const moveAndCompressOptions = {
+ compress: this.options.compress && i === 0,
+ mode: this.options.mode
+ }
await moveAndMaybeCompressFile(
sourceFilePath,
targetFilePath,
- this.options.compress && i === 0
+ moveAndCompressOptions
);
}
@@ -207,7 +232,7 @@ class RollingFileWriteStream extends Writable {
// Sorted from the oldest to the latest
async _getExistingFiles() {
- const files = await fs.readdir(this.fileObject.dir).catch(() => []);
+ const files = await fs.readdir(this.fileObject.dir).catch( /* istanbul ignore next: will not happen on windows */ () => []);
debug(`_getExistingFiles: files=${files}`);
const existingFileDetails = files
@@ -222,7 +247,38 @@ class RollingFileWriteStream extends Writable {
}
_renewWriteStream() {
- fs.ensureDirSync(this.fileObject.dir);
+ const mkdir = (dir) => {
+ try {
+ return fs.mkdirSync(dir, {recursive: true});
+ }
+ // backward-compatible fs.mkdirSync for nodejs pre-10.12.0 (without recursive option)
+ catch (e) {
+ // recursive creation of parent first
+ if (e.code === "ENOENT") {
+ mkdir(path.dirname(dir));
+ return mkdir(dir);
+ }
+
+ // throw error for all except EEXIST and EROFS (read-only filesystem)
+ if (e.code !== "EEXIST" && e.code !== "EROFS") {
+ throw e;
+ }
+
+ // EEXIST: throw if file and not directory
+ // EROFS : throw if directory not found
+ else {
+ try {
+ if (fs.statSync(dir).isDirectory()) {
+ return dir;
+ }
+ throw e;
+ } catch (err) {
+ throw e;
+ }
+ }
+ }
+ };
+ mkdir(this.fileObject.dir);
const filePath = this.fileFormatter({
date: this.state.currentDate,
index: 0
@@ -246,7 +302,7 @@ class RollingFileWriteStream extends Writable {
debug("_clean: existing files are: ", existingFileDetails);
if (this._tooManyFiles(existingFileDetails.length)) {
const fileNamesToRemove = existingFileDetails
- .slice(0, existingFileDetails.length - this.options.numToKeep - 1)
+ .slice(0, existingFileDetails.length - this.options.numToKeep)
.map(f => path.format({ dir: this.fileObject.dir, base: f.filename }));
await deleteFiles(fileNamesToRemove);
}
diff --git a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameFormatter.js b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameFormatter.js
index 81897cf175b..2e6de3d0cb3 100644
--- a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameFormatter.js
+++ b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameFormatter.js
@@ -1,15 +1,17 @@
const debug = require("debug")("streamroller:fileNameFormatter");
const path = require("path");
-const FILENAME_SEP = ".";
const ZIP_EXT = ".gz";
+const DEFAULT_FILENAME_SEP = ".";
module.exports = ({
file,
keepFileExt,
needsIndex,
alwaysIncludeDate,
- compress
+ compress,
+ fileNameSep
}) => {
+ let FILENAME_SEP = fileNameSep || DEFAULT_FILENAME_SEP;
const dirAndName = path.join(file.dir, file.name);
const ext = f => f + file.ext;
diff --git a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameParser.js b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameParser.js
index 8de9a3baf7b..b9e1e38d211 100644
--- a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameParser.js
+++ b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/fileNameParser.js
@@ -1,9 +1,10 @@
const debug = require("debug")("streamroller:fileNameParser");
-const FILENAME_SEP = ".";
const ZIP_EXT = ".gz";
const format = require("date-format");
+const DEFAULT_FILENAME_SEP = ".";
-module.exports = ({ file, keepFileExt, pattern }) => {
+module.exports = ({ file, keepFileExt, pattern, fileNameSep }) => {
+ let FILENAME_SEP = fileNameSep || DEFAULT_FILENAME_SEP;
// All these functions take two arguments: f, the filename, and p, the result placeholder
// They return the filename with any matching parts removed.
// The "zip" function, for instance, removes the ".gz" part of the filename (if present)
diff --git a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/moveAndMaybeCompressFile.js b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/moveAndMaybeCompressFile.js
index b9b6068afda..497933bbdb4 100644
--- a/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/moveAndMaybeCompressFile.js
+++ b/chromium/third_party/devtools-frontend/src/node_modules/streamroller/lib/moveAndMaybeCompressFile.js
@@ -1,12 +1,31 @@
const debug = require('debug')('streamroller:moveAndMaybeCompressFile');
-const fs = require('fs-extra');
+
+const realFs = require('fs');
+const current = realFs.realpath.native;
+if (!realFs.realpath.native) realFs.realpath.native = realFs.realpath;
+let fs = require('fs-extra');
+realFs.realpath.native = current;
+
const zlib = require('zlib');
+const _parseOption = function(rawOptions){
+ const defaultOptions = {
+ mode: parseInt("0600", 8),
+ compress: false,
+ };
+ const options = Object.assign({}, defaultOptions, rawOptions);
+ debug(
+ `_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(options)}`
+ );
+ return options;
+}
+
const moveAndMaybeCompressFile = async (
sourceFilePath,
targetFilePath,
- needCompress
+ options
) => {
+ options = _parseOption(options);
if (sourceFilePath === targetFilePath) {
debug(
`moveAndMaybeCompressFile: source and target are the same, not doing anything`
@@ -17,14 +36,14 @@ const moveAndMaybeCompressFile = async (
debug(
`moveAndMaybeCompressFile: moving file from ${sourceFilePath} to ${targetFilePath} ${
- needCompress ? "with" : "without"
+ options.compress ? "with" : "without"
} compress`
);
- if (needCompress) {
+ if (options.compress) {
await new Promise((resolve, reject) => {
fs.createReadStream(sourceFilePath)
.pipe(zlib.createGzip())
- .pipe(fs.createWriteStream(targetFilePath))
+ .pipe(fs.createWriteStream(targetFilePath, {mode: options.mode}))
.on("finish", () => {
debug(
`moveAndMaybeCompressFile: finished compressing ${targetFilePath}, deleting ${sourceFilePath}`