提交 ffbd9a79 编写于 作者: B Benjamin Pasero

fix #59561

上级 c301189c
......@@ -588,10 +588,24 @@ export class FileService extends Disposable implements IFileService {
else {
// 4.) truncate
let retryFromFailingTruncate = true;
return pfs.truncate(absolutePath, 0).then(() => {
retryFromFailingTruncate = false;
// 5.) set contents (with r+ mode) and resolve
return this.doSetContentsAndResolve(resource, absolutePath, value, addBom, encodingToWrite, { flag: 'r+' });
}, error => {
if (retryFromFailingTruncate) {
if (this.environmentService.verbose) {
console.error(`Truncate failed (${error}), falling back to normal save`);
}
// we heard from users that fs.truncate() fails (https://github.com/Microsoft/vscode/issues/59561)
// in that case we simply save the file without truncating first (same as macOS and Linux)
return this.doSetContentsAndResolve(resource, absolutePath, value, addBom, encodingToWrite);
}
return TPromise.wrapError(error);
});
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册