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);
|
||||
const resourcePath = path.join(this._state!.resourcesDir, sha1);
|
||||
this._appendTraceOperation(async () => {
|
||||
try {
|
||||
// Perhaps we've already written this resource?
|
||||
await fs.promises.access(resourcePath);
|
||||
} catch (e) {
|
||||
// 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(() => {});
|
||||
}
|
||||
// Note: 'wx' flag only writes when the file does not exist.
|
||||
// See https://nodejs.org/api/fs.html#file-system-flags.
|
||||
// This way tracing never have to write the same resource twice.
|
||||
await fs.promises.writeFile(resourcePath, buffer, { flag: 'wx' }).catch(() => {});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user