Skip to content

Commit 547fb0a

Browse files
committed
chore: don't remove files in parallel in order to ensure header and content of files are sent in correct order
1 parent 4480df2 commit 547fb0a

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

lib/definitions/livesync.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ interface IAndroidLivesyncTool {
465465
* @param filePaths - Array of files that will be removed.
466466
* @returns {Promise<boolean[]>}
467467
*/
468-
removeFiles(filePaths: string[]): Promise<void[]>;
468+
removeFiles(filePaths: string[]): Promise<void>;
469469
/**
470470
* Sends doSyncOperation that will be handled by the runtime.
471471
* @param options

lib/services/livesync/android-livesync-tool.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -104,26 +104,27 @@ export class AndroidLivesyncTool implements IAndroidLivesyncTool {
104104
}
105105

106106
public async removeFile(filePath: string): Promise<void> {
107-
this.verifyActiveConnection();
108-
const filePathData = this.getFilePathData(filePath);
109-
const headerBuffer = Buffer.alloc(PROTOCOL_OPERATION_LENGTH_SIZE +
110-
SIZE_BYTE_LENGTH +
111-
filePathData.filePathLengthSize +
112-
filePathData.filePathLengthBytes);
113-
114-
let offset = 0;
115-
offset += headerBuffer.write(AndroidLivesyncTool.DELETE_FILE_OPERATION.toString(), offset, PROTOCOL_OPERATION_LENGTH_SIZE);
116-
offset = headerBuffer.writeInt8(filePathData.filePathLengthSize, offset);
117-
offset += headerBuffer.write(filePathData.filePathLengthString, offset, filePathData.filePathLengthSize);
118-
headerBuffer.write(filePathData.relativeFilePath, offset, filePathData.filePathLengthBytes);
119-
const hash = crypto.createHash("md5").update(headerBuffer).digest();
120-
121-
await this.writeToSocket(headerBuffer);
122-
await this.writeToSocket(hash);
107+
this.verifyActiveConnection();
108+
const filePathData = this.getFilePathData(filePath);
109+
const headerBuffer = Buffer.alloc(PROTOCOL_OPERATION_LENGTH_SIZE +
110+
SIZE_BYTE_LENGTH +
111+
filePathData.filePathLengthSize +
112+
filePathData.filePathLengthBytes);
113+
114+
let offset = 0;
115+
offset += headerBuffer.write(AndroidLivesyncTool.DELETE_FILE_OPERATION.toString(), offset, PROTOCOL_OPERATION_LENGTH_SIZE);
116+
offset = headerBuffer.writeInt8(filePathData.filePathLengthSize, offset);
117+
offset += headerBuffer.write(filePathData.filePathLengthString, offset, filePathData.filePathLengthSize);
118+
headerBuffer.write(filePathData.relativeFilePath, offset, filePathData.filePathLengthBytes);
119+
const hash = crypto.createHash("md5").update(headerBuffer).digest();
120+
121+
await this.writeToSocket(headerBuffer);
122+
await this.writeToSocket(hash);
123123
}
124-
125-
public removeFiles(files: string[]) {
126-
return Promise.all(files.map(file => this.removeFile(file)));
124+
public async removeFiles(files: string[]): Promise<void> {
125+
for (const file of files) {
126+
await this.removeFile(file);
127+
}
127128
}
128129

129130
public generateOperationIdentifier(): string {

0 commit comments

Comments
 (0)