tools/mpremote Copy folder content creates folder on board
Hi,
i noticed a behaviour with mpremote that doesn't seem right. I try to copy the content of a complete folder to the board. But instead of putting the folder content in the root of the device it creates a folder on the device and copies everything there.
Example:
Assume if have to following folder setup:
~/test$ tree mpy-project/
mpy-project/
├── boot.py
├── lib
│ └── urequests.py
└── main.py
I want to put the content of mpy-project on my empty board.
My first attempt was using this command:
mpremote connect /dev/ttyUSB1 cp -r mpy-project/* :
It transferred all files to the board but it was all in a folder called "mpy-project". It looked like that:
~/test$ mpytool -vp /dev/ttyUSB0 tree
./
└─ mpy-project/
├─ lib/
│ └─ urequests.py
├─ boot.py
└─ main.py
That seems counterintuitive for me since the *should be expanded and then the files should be copied.
There is also no use case where that behavior would make sense. If I wanted the complete folder copied I would leave /*out.
Or do i miss something?
Information about the version of MicroPython you're running
- Micropython 1.19.1
- mpremote 0.3.0
- ESP32
mpremote: Behaviour is confusing with multiple mountpoints
Description
Follow on from https://github.com/micropython/micropython/pull/11777#issuecomment-2390338451.
To the naive user of a system with multiple mounted filesystems the behaviour of
$ mpremote cp foo.py :
seems nondeterministic, because the destination of the copy can only be established with knowledge of the state of the target (its current directory). The same applies to
$ mpremote ls :
The following change would provide a deterministic and more discoverable interface.
- Where there is only one mounted filesystem, behaviour remains exactly as currently.
- Where there are multiple filesystems behaviour is as follows:
mpremote ls : produces a list of mountpoints (as per ls : /).
mpremote cp foo.py : throws an exception because you cannot write to '/'.
mpremote cp foo.py :/sd/ works as at present.
While this is a breaking change, an inability to write to '/' will not surprise anyone familiar with the MP directory structure.
Code Size
No response
Implementation
I hope the MicroPython maintainers or community will implement this feature
Code of Conduct
Yes, I agree