File: mergeall-android11-updates-media/MORE--logs-and-code/FTP-server-test.txt
# FTP test, run on macOS (Catalina), in Terminal
# FTP app's server started on Android, on same local Wi-Fi network
#----------------------------------------------------------------------------------------
# 1) Mount server at path (start server in app, Finder 'Go' mounts some server types too)
#----------------------------------------------------------------------------------------
~$ mkdir ~/FtpAndroid
~$ mount_ftp -i ftp://192.168.1.6:2221 ~/FtpAndroid
Username: me
Password:
~$ echo $?
0
#----------------------------------------------------------------------------------------
# 2) The phone's internal storage, as seen on macOS (and by POSIX file calls in Python)
#----------------------------------------------------------------------------------------
~$ ls ~/FtpAndroid
Admin-Mergeall Autodesk Download Movies Pictures Samsung my-0THER-STUFF
Alarms DCIM Icode-Go Music Podcasts Saved Email work
Android Documents MY-STUFF Notifications Ringtones kws
~$ ls ~/FtpAndroid/MY-STUFF
Books Code Music Training Writing __more__
Camera Gadgets Sheets Websites __bkp__
~$ python3
>>> f = open('/Users/me/FtpAndroid/MY-STUFF/Sheets/Goals.xlsb', 'rb')
>>> f.read(10)
b'PK\x03\x04\x14\x00\x06\x00\x08\x00'
>>> f.read(10)
b'\x00\x00!\x00\x9c\x81\xban\xcb\x03'
#----------------------------------------------------------------------------------------
# 3) Run the large-archive comparison benchmark: 17 mins vs USB's 30 secs
#----------------------------------------------------------------------------------------
~$ py3 $C/mergeall/mergeall.py ~/MY-STUFF ~/FtpAndroid/MY-STUFF -report -skipcruft > synclog.txt
~$ grep 'Phase runtime' synclog.txt
Phase runtime: 1026.2403373789998
#----------------------------------------------------------------------------------------
# 4) All files > 6 months old have bad timestamps (12 AM), and others botch seconds
#----------------------------------------------------------------------------------------
~$ cmp /Users/me/MY-STUFF/Music/Music-Popular/ALL/Desperado.mp3 /Users/me/FtpAndroid/MY-STUFF/Music/Music-Popular/ALL/Desperado.mp3
~$
~$ ls -lT /Users/me/MY-STUFF/Music/Music-Popular/ALL/Desperado.mp3 /Users/me/FtpAndroid/MY-STUFF/Music/Music-Popular/ALL/Desperado.mp3
-rw------- 1 me staff 5199676 Feb 2 00:00:00 2011 /Users/me/FtpAndroid/MY-STUFF/Music/Music-Popular/ALL/Desperado.mp3
-rwxrwxrwx 1 me staff 5199676 Feb 2 21:25:06 2011 /Users/me/MY-STUFF/Music/Music-Popular/ALL/Desperado.mp3
~$ cmp /Users/me/MY-STUFF/Sheets/Goals.xlsb /Users/me/FtpAndroid/MY-STUFF/Sheets/Goals.xlsb
~$
~$ ls -lT /Users/me/MY-STUFF/Sheets/Goals.xlsb /Users/me/FtpAndroid/MY-STUFF/Sheets/Goals.xlsb
-rw------- 1 me staff 557773 Mar 13 11:14:00 2021 /Users/me/FtpAndroid/MY-STUFF/Sheets/Goals.xlsb
-rw-r--r--@ 1 me staff 557773 Mar 13 11:14:18 2021 /Users/me/MY-STUFF/Sheets/Goals.xlsb
# But modtimes on phone correctly match macOS PC in both file explorers and Termux 'ls'
#----------------------------------------------------------------------------------------
# 5) The phone is mounted read-only on macOS: one-way (to-PC) syncs only
#----------------------------------------------------------------------------------------
~$ echo "test" > ~/FtpAndroid/test.txt
-bash: /Users/me/FtpAndroid/test.txt: Read-only file system
~$ sudo echo "test" > ~/FtpAndroid/test.txt
-bash: /Users/me/FtpAndroid/test.txt: Read-only file system
#----------------------------------------------------------------------------------------
# 6) Symlinks + nonportable names munged in transit to phone, all files differ by modtime
#----------------------------------------------------------------------------------------
~$ vi synclog.txt
# selected file contents:
Mixed mode:
('FILELINK1',
'/Users/me/MY-STUFF/Code/mergeall/test/ziptools/__private__/TESTS-Comprehensive-apr1320/cgi',
'/Users/me/FtpAndroid/MY-STUFF/Code/mergeall/test/ziptools/__private__/TESTS-Comprehensive-apr1320/cgi'),
Unique:
(['White-throated woodrat \uf027 Neotoma albigula facts.html',
(['White-throated woodrat | Neotoma albigula facts.html',
Diffs:
('Desperado.mp3',
'/Users/me/MY-STUFF/Music/Music-Popular/ALL',
'/Users/me/FtpAndroid/MY-STUFF/Music/Music-Popular/ALL',
'modtime'),
('Goals.xlsb',
'/Users/me/MY-STUFF/Sheets',
'/Users/me/FtpAndroid/MY-STUFF/Sheets',
'modtime'),
#----------------------------------------------------------------------------------------
# 7) [TBD] Port forwarding (with server set to 'Loopback' mode) did not work - why?
#----------------------------------------------------------------------------------------
umount ~/FtpAndroid
adb start-server
adb forward tcp:2221 tcp:2221
mount_ftp -i ftp://127.0.0.1:2221 ~/FtpAndroid
echo $?
py3 $C/mergeall/mergeall.py ~/MY-STUFF ~/FtpAndroid/MY-STUFF -report -skipcruft > synclog2.txt
grep 'Phase runtime' synclog2.txt
#----------------------------------------------------------------------------------------
# 8) [TBD] Results on other platforms? (but a moot point, if servers botch modtimes)
#----------------------------------------------------------------------------------------