Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow get/put folders from/to devices. #1563

Closed
wants to merge 9 commits into from

Conversation

tomriddly
Copy link
Contributor

The original implementation of get and put of afcclient supports only single file. This PR make it work for directories.

@tomriddly
Copy link
Contributor Author

@nikias would you please check if there is further more working or ready for merge?

@nikias
Copy link
Member

nikias commented Apr 28, 2024

Looks good from what I can tell from my phone, but could you
a) use tabs instead of spaces to keep the original formatting intact
b) prefix the 2 commit messages with afclient: followed by the original message (omitting 'afcclient')
(the 3rd commit for .gitignore is fine)

Signed-off-by: tomriddly <tomriddly@qq.com>
Signed-off-by: tomriddly <tomriddly@qq.com>
Signed-off-by: tomriddly <tomriddly@qq.com>
Signed-off-by: tomriddly <tomriddly@qq.com>
@tomriddly
Copy link
Contributor Author

Looks good from what I can tell from my phone, but could you a) use tabs instead of spaces to keep the original formatting intact b) prefix the 2 commit messages with afclient: followed by the original message (omitting 'afcclient') (the 3rd commit for .gitignore is fine)

Done. Commit style and code style are changed

@mexmer
Copy link

mexmer commented Apr 29, 2024

i would suggest adding -r for recursive push/pull, and disable recursive by default. it's common practice for many other commandline copying tools also.

@tomriddly
Copy link
Contributor Author

i would suggest adding -r for recursive push/pull, and disable recursive by default. it's common practice for many other commandline copying tools also.

(s)cp and zip do need a -r option indeed. But on the other hand, adb pull/push will do the transper no matter from a folder or file, which I thought could be the same behaviour of afcclient. I just feel it would be easy to use as what adb has done. Would it be any unforseen risk if we do recursive as default?

@nikias
Copy link
Member

nikias commented Apr 29, 2024

I don't mind without a -r option, but let's make sure that maybe we don't overwrite existing directories. The same actually goes for files, you could easily break your device...

@tomriddly
Copy link
Contributor Author

I don't mind without a -r option, but let's make sure that maybe we don't overwrite existing directories. The same actually goes for files, you could easily break your device...

This make sense, we may need an extra option for overwriting exist files. This PR will write to file directly if we have the write permission(for both side, device and local file system). I would make a change later, maybe a -f flag?

@nikias
Copy link
Member

nikias commented Apr 29, 2024

Yes -f makes sense. Without it and existing we should abort with an error message.

@mexmer
Copy link

mexmer commented Apr 30, 2024

i would suggest adding -r for recursive push/pull, and disable recursive by default. it's common practice for many other commandline copying tools also.

(s)cp and zip do need a -r option indeed. But on the other hand, adb pull/push will do the transper no matter from a folder or file, which I thought could be the same behaviour of afcclient. I just feel it would be easy to use as what adb has done. Would it be any unforseen risk if we do recursive as default?

it's not just cp and zip, abd is rather exception, than "good example". in linux most tools that manipulate files in commandline require -r (some -R) to do recursive work.

adb is bad example for two reasons, major one is, that it does follow symlinks, and doesn't prevent cycling trough links (unless they fixed that, but that bug has been there for years), second is, that it has flawed long path handling (again, unless they fixed it over years)

as for overwrite, i agree that -f (or --force) is good choice.

… to allow recursive

Signed-off-by: tomriddly <tomriddly@qq.com>
Signed-off-by: tomriddly <tomriddly@qq.com>
Signed-off-by: tomriddly <tomriddly@qq.com>
Signed-off-by: tomriddly <tomriddly@qq.com>
Signed-off-by: tomriddly <tomriddly@qq.com>
@tomriddly
Copy link
Contributor Author

i would suggest adding -r for recursive push/pull, and disable recursive by default. it's common practice for many other commandline copying tools also.

(s)cp and zip do need a -r option indeed. But on the other hand, adb pull/push will do the transper no matter from a folder or file, which I thought could be the same behaviour of afcclient. I just feel it would be easy to use as what adb has done. Would it be any unforseen risk if we do recursive as default?

it's not just cp and zip, abd is rather exception, than "good example". in linux most tools that manipulate files in commandline require -r (some -R) to do recursive work.

adb is bad example for two reasons, major one is, that it does follow symlinks, and doesn't prevent cycling trough links (unless they fixed that, but that bug has been there for years), second is, that it has flawed long path handling (again, unless they fixed it over years)

as for overwrite, i agree that -f (or --force) is good choice.

symlinks cycling is what I've never considered, which makes -r may be a necessary option.
I made some updates to support -r and -f, and fix the docs and help messages.

@mexmer
Copy link

mexmer commented May 3, 2024

thanks you, looks good to me.

@tomriddly
Copy link
Contributor Author

@nikias I've run local test and did not find any issue. Could this be merged?

@nikias
Copy link
Member

nikias commented May 18, 2024

I pushed the commits with some small changes, merging the coding style fixes directly into the initial commits and prevent later code-style hiccups. Could you please check with latest commit if this works properly now?

@tomriddly
Copy link
Contributor Author

line 916, additional argc check for get is missing:

else {
	printf("Error: Invalid number of arguments\n");
	return;
}

The other changes seem appropriate to me。

@nikias
Copy link
Member

nikias commented May 20, 2024

See 9ccc522.

@nikias nikias closed this May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants