firebase-tools
firebase-tools copied to clipboard
fix: rm only the content of `exportPath`
Description
I was having trouble with exporting emulator data when I ran an emulator with Docker. It was really hard to find the reason, but I finally found it:
- Emulator tries to remove the export path recursively.
- docker volumes can not be removed, but
rimrafdoesn't throw any error (This is the issue ofrimraf@3. The latest version raises an error as you expect)
- docker volumes can not be removed, but
- then , emulator tries to move the temp data directory to the export path that still exists, so
dest already existsis raised.
Then, the change I made is here:
- Remove the content of the export path, instead of the export path itself
- Then copy the temp directory to the export path
- Remove the temp directory
reproduction
I prepared a different branch for reproduction. You can get the error below with docker compose up --build
https://github.com/m-shaka/firebase-tools/tree/docker-repro
firebase_emulator-1 | i auth: Importing config from /firebase-export/auth_export/config.json
firebase_emulator-1 | i auth: Importing accounts from /firebase-export/auth_export/accounts.json
firebase_emulator-1 | i Running script: 'exit 1'
firebase_emulator-1 | /bin/sh: exit 1: not found
firebase_emulator-1 | ⚠ Script exited unsuccessfully (code 127)
firebase_emulator-1 | i Automatically exporting data using --export-on-exit "/firebase-export" please wait for the export to finish...
firebase_emulator-1 | i Found running emulator hub for project test at http://127.0.0.1:4400
firebase_emulator-1 | i Exporting data to: /firebase-export
firebase_emulator-1 | i emulators: Received export request. Exporting data to /firebase-export.
firebase_emulator-1 | ⚠ emulators: Export failed: dest already exists.
Scenarios Tested
- export data on MacOS (v14.1.2)
- export data on Docker container (Docker for Mac version: 20.10.12)
I'm sorry that I didn't test on Windows
Sample Commands
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.