termux / termux/termux-api-package

termux-download silent fail when set a bad destination path

Open
#118 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
1.7k
Forks
523
PR merge metrics
No merged PRs in 30d

Description

Problem description
When I try to save a downloaded file, using termux-download with -p to a Termux internal path, nothing happens. No error are throw to the console and no notification on the android interface.

It works to /storage/emulated/0/Download/ however it wont work to $HOME/storage/downloads, even with it pointing to the first path.

Steps to reproduce
Step 1 - Run:
termux-download -d 'some picture' -t 'hyperbola' -p $HOME/gnu.jpg http://www.gnu.org/distros/screenshots/hyperbola-i3-thumb.jpg
Step 2 - no step two... that fails without log

Expected behavior
It must show the download on the Android notification and save the file on the destination set with -p parameter.

If it really can't download to $HOME, it must throw an error. It must write to STDERR and exit with a non zero status.

Paths like $HOME/storage/downloads must be translated with realpath by termux-download itself.

Additional information
All tests were made in a emulated device.

Post output of command termux-info.

Packages CPU architecture:
i686
Subscribed repositories:
# sources.list
deb https://grimler.se/termux-packages-24/ stable main
# game-repo (sources.list.d/game.list)
deb https://dl.bintray.com/grimler/game-packages-24 games stable
# science-repo (sources.list.d/science.list)
deb https://dl.bintray.com/grimler/science-packages-24 science stable
# x11-repo (sources.list.d/x11.list)
deb https://dl.bintray.com/xeffyr/x11-packages x11 main
Updatable packages:
apt/stable 2.1.15 i686 [upgradable from: 2.1.11-2]
bash/stable 5.1.4 i686 [upgradable from: 5.0.18-4]
ca-certificates/stable 20201208 all [upgradable from: 20201027]
command-not-found/stable 1.60 i686 [upgradable from: 1.59]
coreutils/stable 8.32-7 i686 [upgradable from: 8.32-6]
curl/stable 7.74.0 i686 [upgradable from: 7.73.0]
dash/stable 0.5.11.3 i686 [upgradable from: 0.5.11.2-4]
dpkg/stable 1.20.5-5 i686 [upgradable from: 1.20.5-4]
gpgv/stable 2.2.26 i686 [upgradable from: 2.2.23]
libcurl/stable 7.74.0 i686 [upgradable from: 7.73.0]
libgmp/stable 6.2.1 i686 [upgradable from: 6.2.0-1]
libgpg-error/stable 1.41 i686 [upgradable from: 1.39]
liblz4/stable 1.9.3 i686 [upgradable from: 1.9.2]
libnettle/stable 3.7 i686 [upgradable from: 3.6]
libnghttp2/stable 1.42.0 i686 [upgradable from: 1.41.0-1]
libtirpc/stable 1.3.1 i686 [upgradable from: 1.2.6-1]
lsof/stable 4.94.0 i686 [upgradable from: 4.93.2]
nano/stable 5.4 i686 [upgradable from: 5.3]
net-tools/stable 2.10.0 i686 [upgradable from: 1.60.2017.02.21-3]
openssl/stable 1.1.1i i686 [upgradable from: 1.1.1h]
readline/stable 8.1.0 i686 [upgradable from: 8.0.4-1]
termux-am/stable 0.4 all [upgradable from: 0.3]
termux-tools/stable 0.104 all [upgradable from: 0.97]
tsu/stable 8.5.1-3 all [upgradable from: 8.5.1-2]
util-linux/stable 2.36.1 i686 [upgradable from: 2.36]
Android version:
8.0.0
Kernel build information:
Linux localhost 4.4.34-genymotion #1 SMP PREEMPT Fri Jan 31 08:31:47 UTC 2020 i686 Android
Device manufacturer:

Device model:
Google Pixel 2 API 8

If you are rooted or have access to adb then capture a logcat with logcat -d "*:W", from a adb or root shell.

01-14 00:20:24.387  3763 16209 E memtrack: Couldn't load memtrack module
01-14 00:20:24.387  3763 16209 W android.os.Debug: failed to get memory consumption info: -1
01-14 00:20:40.927  6605  6605 E DecorView[]: Destroying unexpected ActionMode instance of TYPE_FLOATING; com.android.internal.view.FloatingActionMode@202ff60 was not the current floating action mode! Expected null
01-14 00:20:41.154 16213 16213 W /system/bin/app_process: Unexpected CPU variant for X86 using defaults: x86
01-14 00:20:41.156 16213 16213 W /system/bin/app_process: Could not create mount namespace.
01-14 00:20:41.156 16213 16213 W nativebridge: Failed to bind-mount /system/lib/x86/cpuinfo as /proc/cpuinfo: Operation not permitted
01-14 00:20:41.185 13608 13626 W DownloadManager: Path appears to be invalid: /data/data/com.termux/files/home/storage/downloads/gnu.jpg
01-14 00:20:41.185 13608 13626 W DownloadManager: Path appears to be invalid: /data/data/com.termux/files/home/storage/downloads/gnu.jpg
01-14 00:20:41.185 13608 13626 E DatabaseUtils: Writing exception to parcel
01-14 00:20:41.185 13608 13626 E DatabaseUtils: java.lang.SecurityException: Unsupported path /data/data/com.termux/files/home/storage/downloads/gnu.jpg
01-14 00:20:41.185 13608 13626 E DatabaseUtils: 	at com.android.providers.downloads.DownloadProvider.checkFileUriDestination(DownloadProvider.java:808)
01-14 00:20:41.185 13608 13626 E DatabaseUtils: 	at com.android.providers.downloads.DownloadProvider.insert(DownloadProvider.java:599)
01-14 00:20:41.185 13608 13626 E DatabaseUtils: 	at android.content.ContentProvider$Transport.insert(ContentProvider.java:267)
01-14 00:20:41.185 13608 13626 E DatabaseUtils: 	at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:152)
01-14 00:20:41.185 13608 13626 E DatabaseUtils: 	at android.os.Binder.execTransact(Binder.java:674)
01-14 00:20:41.186 12485 16222 E termux-api: Error in ResultReturner
01-14 00:20:41.186 12485 16222 E termux-api: java.lang.SecurityException: Unsupported path /data/data/com.termux/files/home/storage/downloads/gnu.jpg
01-14 00:20:41.186 12485 16222 E termux-api: 	at android.os.Parcel.readException(Parcel.java:1942)
01-14 00:20:41.186 12485 16222 E termux-api: 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
01-14 00:20:41.186 12485 16222 E termux-api: 	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
01-14 00:20:41.186 12485 16222 E termux-api: 	at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
01-14 00:20:41.186 12485 16222 E termux-api: 	at android.content.ContentResolver.insert(ContentResolver.java:1539)
01-14 00:20:41.186 12485 16222 E termux-api: 	at android.app.DownloadManager.enqueue(DownloadManager.java:1041)
01-14 00:20:41.186 12485 16222 E termux-api: 	at com.termux.api.DownloadAPI.lambda$onReceive$0(DownloadAPI.java:41)
01-14 00:20:41.186 12485 16222 E termux-api: 	at com.termux.api.-$$Lambda$DownloadAPI$4YhREMVDJjtX4lY26y4bbDIrLiw.writeResult(Unknown Source:4)
01-14 00:20:41.186 12485 16222 E termux-api: 	at com.termux.api.util.ResultReturner.lambda$returnData$0(ResultReturner.java:133)
01-14 00:20:41.186 12485 16222 E termux-api: 	at com.termux.api.util.-$$Lambda$ResultReturner$oCU8JqHW5HLMrNZa40ThjAWcwzo.run(Unknown Source:8)
01-14 00:20:41.186 12485 16222 E termux-api: 	at java.lang.Thread.run(Thread.java:764)
01-14 00:20:45.441   656  6451 W MessageQueue: Handler (android.media.MediaPlayer$EventHandler) {24659ce} sending message to a Handler on a dead thread
01-14 00:20:45.441   656  6451 W MessageQueue: java.lang.IllegalStateException: Handler (android.media.MediaPlayer$EventHandler) {24659ce} sending message to a Handler on a dead thread
01-14 00:20:45.441   656  6451 W MessageQueue: 	at android.os.MessageQueue.enqueueMessage(MessageQueue.java:545)
01-14 00:20:45.441   656  6451 W MessageQueue: 	at android.os.Handler.enqueueMessage(Handler.java:661)
01-14 00:20:45.441   656  6451 W MessageQueue: 	at android.os.Handler.sendMessageAtTime(Handler.java:630)
01-14 00:20:45.441   656  6451 W MessageQueue: 	at android.os.Handler.sendMessageDelayed(Handler.java:600)
01-14 00:20:45.441   656  6451 W MessageQueue: 	at android.os.Handler.sendMessage(Handler.java:537)
01-14 00:20:45.441   656  6451 W MessageQueue: 	at android.media.MediaPlayer.postEventFromNative(MediaPlayer.java:3436)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the termux-download entry point and the DownloadAPI.java stack-trace location, then reproduce the -p failure using a Termux-internal path. Check how the failed enqueue result is handled; done means the command reports the failure on STDERR with a non-zero status, while valid destinations still download and notify.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, shell
Domain
cli, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.