mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1676803 - [remote] Hardening discards of registered FileIO streams. r=remote-protocol-reviewers,jdescottes
In some situations the FileIO stream's underlying file might not exist anymore. Discarding the stream should not fail. Depends on D112004 Differential Revision: https://phabricator.services.mozilla.com/D113379
This commit is contained in:
parent
8bcc373610
commit
460f0ed59f
@ -47,14 +47,16 @@ class StreamRegistry {
|
||||
|
||||
async _discard(stream) {
|
||||
if (stream instanceof OS.File) {
|
||||
const fileInfo = await stream.stat();
|
||||
stream.close();
|
||||
let fileInfo;
|
||||
|
||||
// Also remove the temporary file
|
||||
try {
|
||||
fileInfo = await stream.stat();
|
||||
|
||||
stream.close();
|
||||
await OS.File.remove(fileInfo.path, { ignoreAbsent: true });
|
||||
} catch (e) {
|
||||
console.error(`Failed to remove ${fileInfo.path}: ${e.message}`);
|
||||
console.error(`Failed to remove ${fileInfo?.path}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user