AmirHmZz / mpbridge

CLI tool to synchronise and manage files on MicroPython running devices
https://pypi.org/project/mpbridge
MIT License
49 stars 5 forks source link

When using the sync function, what if we need to delete some files on the board? #11

Closed Wind-stormger closed 1 year ago

Wind-stormger commented 1 year ago

Currently, sync will perform a check and compare, and then pull the files that are not in the local folder from the board to the local, and then push the files that are not on the board or have changed locally to the board.

But what if we need to delete some files on the board?

Suppose, when we need to switch projects to use on the same board, the content of many files or folders will be useless and occupy the flash.

At this time, some methods are needed, such as setting an additional requirement when syncing, only based on the files in the local folder, checking redundant files or subfolders on the board, and deleting them.

Wind-stormger commented 1 year ago

I guess you already have a plan for this. @AmirHmZz

AmirHmZz commented 1 year ago

Currently, sync will perform a check and compare, and then pull the files that are not in the local folder from the board to the local, and then push the files that are not on the board or have changed locally to the board.

Yes, but with a difference, Currently it will:

  1. Push files that they don't exist / updated to board
  2. Pull files that they don't exist / updated from board

To achieve what you've said, We have three possible options:

  1. Use bridge mode to delete files: This solution is not good enough because takes a lot of time to copy files to local device which is an unnecessary operation.
  2. Add an option to sync command and dev mode like -c to clear flash storge before sync.
  3. Add a new command like mpbridge clear to clear flash storage.

Solution 2 and 3 can be used together, I mean we can have a -c option beside the new clear command. What's your opinion?

Wind-stormger commented 1 year ago

Maybe a --force is enough. When using it, only sync based on the local directory, remove files that are not in the local directory, and synchronize changes in the local directory. In my opinion, there is no need for an additional clean function. Because if I want to switch from project A to project B, they all depend on the two files ab.py and cd.py, you only need to remove the files that do not exist in project B. Even if we need to delete all files, we only need to delete the files in the local folder.

AmirHmZz commented 1 year ago

@Wind-stormger Now you are able to perform a clean sync. Upgrade your mpbridge to v1.1. Thanks.

Wind-stormger commented 1 year ago

Very nice! At the same time, I hope dev can also have this feature.