vidstige / jadb

ADB Client in pure Java.
Apache License 2.0
640 stars 178 forks source link

JadbDevice.pull() doesn't work using files from list() #156

Closed jpage4500 closed 6 months ago

jpage4500 commented 6 months ago

I noticed the pull() method doesn't work when passing in a RemoteFile taken from the list() command

I think the reason is because RemoteFile.getPath() just returns the file name and not the full path -- as mentioned here

The issue was closed as intended behavior but it seems like the RECV command is issued with just the file name. So, I'm guessing it should be the full path instead

    public void pull(RemoteFile remote, OutputStream destination) throws IOException, JadbException {
...
            sync.send("RECV", remote.getPath());
jpage4500 commented 6 months ago

I was able to fix this in the library by modifying RemoteFile to take the full path as well as the name

vidstige commented 6 months ago

This is expected. You need to concat the directory listed with the filename returned. This is akin to how most tools in linux and also windows work. For example

$ ls directory/
file.txt

Note that the file is listed as a relative path to the directory/. If you want to do something with file.txt inside diectory/ you need to concatenate the directory with the filename like so

$ rm ditectory/file.txt

If you instead only use the filename, it will not work as it will reference a file in the current directory.