@@ -345,9 +345,10 @@ information.
345
345
#### ` pyscript.fs.mount `
346
346
347
347
Mount a directory on the user's local filesystem into the browser's virtual
348
- filesystem. If no previous transient user activation has taken place, this
349
- function will result in a minimalist dialog to provide the
350
- [ transient user activation] ( https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation ) .
348
+ filesystem. If no previous
349
+ [ transient user activation] ( https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation )
350
+ has taken place, this function will result in a minimalist dialog to provide
351
+ the required transient user activation.
351
352
352
353
This asynchronous function takes four arguments:
353
354
@@ -356,7 +357,9 @@ This asynchronous function takes four arguments:
356
357
* ` mode ` (default: ` "readwrite" ` ) - indicates how the code may interact with
357
358
the mounted filesystem. May also be just ` "read" ` for read-only access.
358
359
* ` id ` (default: ` "pyscript" ` ) - indicate a unique name for the handler
359
- associated with a directory on the user's local filesystem.
360
+ associated with a directory on the user's local filesystem. This allows users
361
+ to select different folders and mount them at the same path in the
362
+ virtual filesystem.
360
363
* ` root ` (default: ` "" ` ) - a hint to the browser for where to start picking the
361
364
path that should be mounted in Python. Valid values are: ` desktop ` ,
362
365
` documents ` , ` downloads ` , ` music ` , ` pictures ` or ` videos ` as per
@@ -370,6 +373,23 @@ from pyscript import fs
370
373
await fs.mount(" /local" )
371
374
```
372
375
376
+ If the call to ` fs.mount ` happens after a click or other transient event, the
377
+ confirmation dialog will not be shown.
378
+
379
+ ``` python title="Mounting without a transient event dialog."
380
+ from pyscript import fs
381
+
382
+
383
+ async def handler (event ):
384
+ """
385
+ The click event that calls this handler is already a transient event.
386
+ """
387
+ await fs.mount(" /local" )
388
+
389
+
390
+ my_button.onclick = handler
391
+ ```
392
+
373
393
#### ` pyscript.fs.sync `
374
394
375
395
Given a named ` path ` for a mount point on the browser's virtual filesystem,
@@ -384,8 +404,8 @@ await fs.sync("/local")
384
404
#### ` pyscript.fs.unmount `
385
405
386
406
Asynchronously unmount the named ` path ` from the browser's virtual filesystem.
387
- This will free up memory. A call to [ ` fs.sync ` ] ( #pyscriptfssync ) is
388
- automatically made before unmounting .
407
+ This will free up memory and allow you to re-use the path to mount a different
408
+ directory .
389
409
390
410
``` python title="Unmount from the virtual filesystem."
391
411
await fs.unmount(" /local" )
0 commit comments