Catfriend1 / syncthing-android

Syncthing-Fork - A Syncthing Wrapper for Android.
Mozilla Public License 2.0
2.12k stars 63 forks source link

Default folder path: Home shortcut (~) broken #1146

Open r748 opened 1 month ago

r748 commented 1 month ago

Description of the issue

According to the documentation, when changing the location of the default folder, the tilde character (~) acts as shortcut to /storage/emulated/0. Folders synced to the mobile device are correctly created under this path, but syncthing-fork doesn't seem to replace the ~ character with /storage/emulated/0 when trying to access a folder in the default path.

Reproduction Steps

  1. Set the default folder in the web interface on the mobile phone to ~/Syncthing
  2. Sync a folder from another device to the mobile phone
  3. The synced folder is correctly created under /storage/emulated/0/Syncthing/sharedfolder
  4. In the Folders view of syncthing-fork click on the folder icon of this shared folder
  5. Material files will try to open the path ~/Syncthing/sharedfolder instead of /storage/emulated/0/Syncthing/sharedfolder and fail to do succeed
  6. Share a file from e.g. your Gallery or a file explorer to syncthing-fork. Sharing will fail, because the path ~/Syncthing/sharedfolder cannot be found.

Version Information

Device platform info

[ro.product.board]: [pineapple]
[ro.product.bootimage.brand]: [samsung]
[ro.product.bootimage.device]: [e3q]
[ro.product.bootimage.manufacturer]: [samsung]
[ro.product.bootimage.model]: [SM-S928B]
[ro.product.bootimage.name]: [e3qxxx]
[ro.product.brand]: [samsung]
[ro.product.build.date]: [Fri Aug 16 18:24:38 KST 2024]
[ro.product.build.date.utc]: [1723800278]
[ro.product.build.fingerprint]: [samsung/e3qxxx/qssi_64:14/UP1A.231005.007/S928BXXU3AXH7:user/release-keys]
[ro.product.build.id]: [UP1A.231005.007]
[ro.product.build.tags]: [release-keys]
[ro.product.build.type]: [user]
[ro.product.build.version.incremental]: [S928BXXU3AXH7]
[ro.product.build.version.release]: [14]
[ro.product.build.version.release_or_codename]: [14]
[ro.product.build.version.sdk]: [34]
[ro.product.cpu.abi]: [arm64-v8a]
[ro.product.cpu.abilist]: [arm64-v8a]
[ro.product.cpu.abilist32]: []
[ro.product.cpu.abilist64]: [arm64-v8a]
[ro.product.cpu.pagesize.max]: [4096]
[ro.product.device]: [e3q]
[ro.product.device_for_attestation]: [e3q]
[ro.product.first_api_level]: [34]
[ro.product.locale]: [en-GB]
[ro.product.manufacturer]: [samsung]
[ro.product.model]: [SM-S928B]
[ro.product.name]: [e3qxeea]
[ro.product.odm.brand]: [samsung]
[ro.product.odm.device]: [e3q]
[ro.product.odm.manufacturer]: [samsung]
[ro.product.odm.model]: [SM-S928B]
[ro.product.odm.name]: [e3qxxx]
[ro.product.product.brand]: [samsung]
[ro.product.product.device]: [qssi_64]
[ro.product.product.manufacturer]: [samsung]
[ro.product.product.model]: [SM-S928B]
[ro.product.product.name]: [e3qxxx]
[ro.product.system.brand]: [samsung]
[ro.product.system.device]: [qssi_64]
[ro.product.system.manufacturer]: [samsung]
[ro.product.system.model]: [SM-S928B]
[ro.product.system.name]: [e3qxxx]
[ro.product.system_dlkm.brand]: [samsung]
[ro.product.system_dlkm.device]: [e3q]
[ro.product.system_dlkm.manufacturer]: [samsung]
[ro.product.system_dlkm.model]: [SM-S928B]
[ro.product.system_dlkm.name]: [e3qxxx]
[ro.product.system_ext.brand]: [samsung]
[ro.product.system_ext.device]: [qssi_64]
[ro.product.system_ext.manufacturer]: [samsung]
[ro.product.system_ext.model]: [SM-S928B]
[ro.product.system_ext.name]: [e3qxxx]
[ro.product.vendor.brand]: [samsung]
[ro.product.vendor.device]: [e3q]
[ro.product.vendor.manufacturer]: [samsung]
[ro.product.vendor.model]: [SM-S928B]
[ro.product.vendor.name]: [e3qxxx]
[ro.product.vendor_dlkm.brand]: [samsung]
[ro.product.vendor_dlkm.device]: [e3q]
[ro.product.vendor_dlkm.manufacturer]: [samsung]
[ro.product.vendor_dlkm.model]: [SM-S928B]
[ro.product.vendor_dlkm.name]: [e3qxxx]
[ro.product.vndk.version]: [34]
[ro.product_ship]: [true]

Android Log

20:25:05E/ShareActivity Can't find input file "content://media/external/images/media/1000017388" to copy
20:25:05E/ShareActivity java.io.FileNotFoundException: ~/Syncthing/Sitzplatzüberdachung 2024/IMG_20200411_175344.jpg: open failed: ENOENT (No such file or directory)
20:25:05E/ShareActivity     at libcore.io.IoBridge.open(IoBridge.java:574)
20:25:05E/ShareActivity     at java.io.FileOutputStream.<init>(FileOutputStream.java:236)
20:25:05E/ShareActivity     at com.google.common.io.Files$FileByteSink.openStream(Files.java:193)
20:25:05E/ShareActivity     at com.google.common.io.Files$FileByteSink.openStream(Files.java:181)
20:25:05E/ShareActivity     at com.google.common.io.ByteSink.writeFrom(ByteSink.java:124)
20:25:05E/ShareActivity     at com.nutomic.syncthingandroid.activities.ShareActivity$CopyFilesTask.doInBackground(ShareActivity.java:423)
20:25:05E/ShareActivity     at com.nutomic.syncthingandroid.activities.ShareActivity$CopyFilesTask.doInBackground(ShareActivity.java:382)
20:25:05E/ShareActivity     at android.os.AsyncTask$3.call(AsyncTask.java:394)
20:25:05E/ShareActivity     at java.util.concurrent.FutureTask.run(FutureTask.java:264)
20:25:05E/ShareActivity     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
20:25:05E/ShareActivity     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
20:25:05E/ShareActivity     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
20:25:05E/ShareActivity     at java.lang.Thread.run(Thread.java:1012)
20:25:05E/ShareActivity Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
20:25:05E/ShareActivity     at libcore.io.Linux.open(Native Method)
20:25:05E/ShareActivity     at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
20:25:05E/ShareActivity     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
20:25:05E/ShareActivity     at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
20:25:05E/ShareActivity     at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8926)
20:25:05E/ShareActivity     at libcore.io.IoBridge.open(IoBridge.java:560)
20:25:05E/ShareActivity     ... 12 more
Catfriend1 commented 1 month ago

The wrapper does not know what "~" is , especially the problem is that Android more tends to prefer SAF paths over absolute paths which made development a little bit tricky the last years to preserve the absolute folder paths SyncthingNative requires to work with.