Avoid double recording in iOSDevice

Summary: This should in theory never happen since the state of the recording is also managed within the UI. However, it's better to ensure that if `startRecording` is called twice, without calling `stopRecording` first it will error rather than leak a recording (the first process will still run but the object representing it is oprhaned)

Reviewed By: passy

Differential Revision: D33913298

fbshipit-source-id: f8fa6b0e4fdbdf4282633fa29a736d3e7dedf3bb
This commit is contained in:
Lawrence Lomax
2022-02-01 04:55:51 -08:00
committed by Facebook GitHub Bot
parent 7d34c86f78
commit 3a9c875e03

View File

@@ -81,6 +81,12 @@ export default class IOSDevice extends ServerDevice {
}
async startScreenCapture(destination: string) {
const recording = this.recording;
if (recording) {
throw new Error(
`There is already an active recording at ${recording.destination}`,
);
}
const process = this.iOSBridge.recordVideo(this.serial, destination);
this.recording = {process, destination};
}