aafm icon indicating copy to clipboard operation
aafm copied to clipboard

aafm quietly fails to work when dir names include some chars

Open archont00 opened this issue 8 years ago • 4 comments

Note that it fails quietly, which is pretty dangerous in case of copying whole directory structure. Due to this bug, such a directory appears empty even when there are files in it.

EXECUTE ('adb', '-s', '343637ff', 'shell', 'ls', '-l', '-a', '/mnt/sdcard/z_Various/AppsOther/swyping for AOSP keyboard/')
/mnt/sdcard/z_Various/AppsOther/swyping: No such file or directory wasn't matched, please report to the developer!
for: No such file or directory wasn't matched, please report to the developer!
AOSP: No such file or directory wasn't matched, please report to the developer!
keyboard/: No such file or directory wasn't matched, please report to the developer!

archont00 avatar Oct 15 '16 12:10 archont00

Okay, it fails to work also when other chars are in the file names: space, (, ), & and possibly others. When tested in CLI (bash) with back-slash escaping, then adb command works. Putting the path/file in single quotes is not enough.

archont00 avatar Oct 15 '16 14:10 archont00

I faced the same issue when accessing folders with special characters. A crude workaround would be to replace the shell arguments with back-slash escaping (for adb shell commands only, not for push/pull requests), and to add double-quotes around the path name. Modifying the execute function in Aafm.py to the following has worked so far for me:

def execute(self, *args):
	args_list = list(args)
	command = ""
	is_file_transfer = False
	for i in range(len(args_list)):
		if args_list[i] == "push" or args_list[i] == "pull":
			is_file_transfer = True
		if args_list[i][0] == "/":
			args_list[i] = r'"' + args_list[i] + r'"'
			if is_file_transfer == False:
				args_list[i] = args_list[i].replace(r" ",r"\ ")
				args_list[i] = args_list[i].replace(r"'",r"\'")
		command = command + args_list[i] + " "
	print command
	proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
	return filter(None, [line.rstrip('\r\n') for line in proc.stdout])

yeoweizheng avatar Aug 08 '17 16:08 yeoweizheng

Yei it works! Thanks!

xeruf avatar Jun 18 '18 20:06 xeruf

I have now incorporated these changes into my fork, also escaping other chars like &

xeruf avatar Jun 19 '18 17:06 xeruf