mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore(tracing): remove extra fs.access call (#21855)
This commit is contained in:
parent
d9a9bb5a8c
commit
295a8ec92b
@ -421,14 +421,10 @@ export class Tracing extends SdkObject implements InstrumentationListener, Snaps
|
|||||||
this._allResources.add(sha1);
|
this._allResources.add(sha1);
|
||||||
const resourcePath = path.join(this._state!.resourcesDir, sha1);
|
const resourcePath = path.join(this._state!.resourcesDir, sha1);
|
||||||
this._appendTraceOperation(async () => {
|
this._appendTraceOperation(async () => {
|
||||||
try {
|
// Note: 'wx' flag only writes when the file does not exist.
|
||||||
// Perhaps we've already written this resource?
|
// See https://nodejs.org/api/fs.html#file-system-flags.
|
||||||
await fs.promises.access(resourcePath);
|
// This way tracing never have to write the same resource twice.
|
||||||
} catch (e) {
|
await fs.promises.writeFile(resourcePath, buffer, { flag: 'wx' }).catch(() => {});
|
||||||
// If not, let's write! Note that async access is safe because we
|
|
||||||
// never remove resources until the very end.
|
|
||||||
await fs.promises.writeFile(resourcePath, buffer).catch(() => {});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user