Butterfly icon indicating copy to clipboard operation
Butterfly copied to clipboard

[Bug]: use existing directory of butterfly files with another installation

Open Tumypmyp opened this issue 3 weeks ago • 9 comments

What happened?

I have directory in ./Documents for Butterfly files, but a can not add it as data folder an Android. This prevents from using both nightly and stable version on the same device, and also using the app from other device with synced storage.

Version

2.4.1

Platform

Android

Relevant log output


Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

Tumypmyp avatar Dec 04 '25 20:12 Tumypmyp

Im not sure what you mean. You can change the data directory in the settings

CodeDoctorDE avatar Dec 04 '25 21:12 CodeDoctorDE

The bug is: After I confirm the choosen directory it is not set in the app. The app data dir is Default. App does not show the expected files.

https://github.com/user-attachments/assets/4aa7ea80-fe19-48fb-b004-848e5b2ac83f

Tumypmyp avatar Dec 04 '25 22:12 Tumypmyp

Strange, tested it myself and it works correctly and will be changed successfully. Can you give me more specific information about your device?

CodeDoctorDE avatar Dec 05 '25 12:12 CodeDoctorDE

Hello, @Tumypmyp !

Can you please provide more detail? Neither @CodeDoctorDE or I understand the issue.

Please provide the steps for how to reproduce the issue. AND Explain in detail what are you expecting, and what is happening instead,

Thank you!

JerryMerweather avatar Dec 05 '25 14:12 JerryMerweather

  1. Install app
  2. Set data dir as some internal memory path
  3. Create a file
  4. Clear app data/cash (or use another installation of the app for the next steps. This step emulates the environment for when I sync the files to another android device, and then setup the app data dir there)
  5. Set app data from default to the same internal memory path.
  6. The data dir does not change and is the default.

I suspect from how the data dir behaves that the app tries to copy the new generated data dir (like templates) from the app storage to the internal memory dir with existing already dirs and files and fails.

The app should instead do any of:

  • change the dir without coping files
  • merge the source and destination dirs
  • give option to choose from both behaviours
  • give a warning that move wasn't successful

Tumypmyp avatar Dec 05 '25 18:12 Tumypmyp

Okay... does this also happen in the nightly version?

CodeDoctorDE avatar Dec 05 '25 18:12 CodeDoctorDE

Yes

Tumypmyp avatar Dec 05 '25 18:12 Tumypmyp

Can reproduce it, but sadly looks like an android specific permission issue:

E/flutter ( 5910): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PathAccessException: Cannot copy file to '/storage/emulated/0/Documents/Butterfly/Templates/Light.bfly', path = '/storage/emulated/0/Android/data/dev.linwood.butterfly.nightly/files/Linwood/Butterfly/Templates/Light.bfly' (OS Error: Permission denied, errno = 13)

I'm open for ideas/pull requests that fixes the issue.

The problem is this: I'm using ACTION_OPEN_DOCUMENT_TREE to get the folder with file picker: https://github.com/miguelpruivo/flutter_file_picker.

https://developer.android.com/training/data-storage/shared/documents-files?hl=en#grant-access-directory

https://github.com/miguelpruivo/flutter_file_picker/blob/33476e19bb660c4258e8f4b46b28ddbe7749384b/android/src/main/kotlin/com/mr/flutter/plugin/filepicker/FileUtils.kt#L135

CodeDoctorDE avatar Dec 06 '25 15:12 CodeDoctorDE

I am having a similar issue with version Black Hairstreak 2.4.2-rc.2.

In the video below, I set the setting "Data directory" to a folder in Internal Storage. I created a new directory called butterfly-test-1. After pressing the button "Allow", Butterfly, kept showing "Default path" as the value for "Data directory". This is a bug, Butterfly should have shown butterfly-test-1 as the value for "Data directory" after I pressed the button "Allow".

In the video, I also created a note foo.bfly, but when I visit the directory using a file explorer, the folder has the directory "Templates", but no other file. This is another bug, Butterfly should have saved the note foo.bfly inside the directory butterfly-test-1.

https://github.com/user-attachments/assets/c930e724-b08a-4cef-83c3-186d5cae26a4

System information:

Device model: Galaxy Tab S6 Lite Android version: 15

rodrigo-morales-1 avatar Dec 06 '25 22:12 rodrigo-morales-1