mirror of
https://github.com/jupyterlite/jupyterlite.git
synced 2025-09-06 04:33:31 +00:00
Backport PR #1714: Fix: Drive issue on rewritting JSON file (#1716)
Some checks failed
Check Release / check_release (push) Has been cancelled
UI Tests / Build (push) Has been cancelled
UI Tests / Visual Regression (chromium) (push) Has been cancelled
UI Tests / Visual Regression (firefox) (push) Has been cancelled
Some checks failed
Check Release / check_release (push) Has been cancelled
UI Tests / Build (push) Has been cancelled
UI Tests / Visual Regression (chromium) (push) Has been cancelled
UI Tests / Visual Regression (firefox) (push) Has been cancelled
Co-authored-by: martinRenou <martin.renou@gmail.com>
This commit is contained in:

committed by
GitHub

parent
e91e245207
commit
44c74bd069
@@ -225,7 +225,7 @@ export class DriveContentsProcessor implements IDriveContentsProcessor {
|
||||
async put(request: TDriveRequest<'put'>): Promise<TDriveResponse<'put'>> {
|
||||
await this.contentsManager.save(request.path, {
|
||||
content:
|
||||
request.data.format === 'json'
|
||||
request.data.format === 'json' && request.data.data
|
||||
? JSON.parse(request.data.data)
|
||||
: request.data.data,
|
||||
type: 'file',
|
||||
|
46
ui-tests/contents/file-access-3.ipynb
Normal file
46
ui-tests/contents/file-access-3.ipynb
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e3c4d1de",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"s = R\"\"\"\n",
|
||||
"{\n",
|
||||
" \"args\": {}\n",
|
||||
"}\n",
|
||||
"\"\"\"\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"data = json.loads(s)\n",
|
||||
"with open(\"data.json\", \"w\") as f:\n",
|
||||
" json.dump(data, f)\n",
|
||||
"with open(\"data.json\", \"w\") as f:\n",
|
||||
" json.dump(data, f)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python (Pyodide)",
|
||||
"language": "python",
|
||||
"name": "python"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
@@ -95,4 +95,13 @@ test.describe('Service Worker Tests', () => {
|
||||
expect(output).toBeTruthy();
|
||||
expect(output![0]).toContain(expectedOutput);
|
||||
});
|
||||
|
||||
test('Create a JSON file twice does not crash the kernel', async ({ page }) => {
|
||||
const notebook = 'file-access-3.ipynb';
|
||||
|
||||
await page.menu.clickMenuItem('Settings>Autosave Documents');
|
||||
|
||||
await page.notebook.open(notebook);
|
||||
await page.notebook.runCellByCell();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user