Possible causes for MTP syncing failures

Get help for specific problems
Posts: 12
Joined: 15 Sep 2018

Lyrus

Hi Zenju,

I have been using FFS for many years and I'm happy with it, but I am resigned to the fact that the MTP syncing doesn't work.

And I see that even for other people doesn't work. I tried with every new version and with various phones. Does it work only in phones with root permissions? (Never tried one)

However I tried some tests last time with version 11.8 and I did some considerations.

In a folder on the PC I put these files:
A.txt
B.txt
C.txt
D.txt

And I synchronized it with a folder on mobile. It went well and so at the beginning the two folders were identical.
Then I made various tests consisting, for example, of:

Delete A.txt from the PC
Delete B.txt from the Phone
Edit C.txt on PC
Edit D.txt on Phone

I do not describe all the tests in detail but only some that seem to have significance.

After the first synchronization all subsequent ones did not work. The comparison is fine but when the synchronization is launched, as described by other people too, FFS get stuck and does not go ahead. You have to disconnect the phone and reconnect it.

I remembered that FFS can do what you can do manually with File Explorer. And what can't be done manually even FFS can't do.
And I also reminded that if I open a file on the phone directly from the PC and I modify it, then I can't save it. I have to save as a new file.

So may be that FFS freeze because it opens the sync.ffs_db database on the phone, modifies it and then tries to save.

To test it I made a comparison, then I deleted the database on the phone, then I launched the synchronization. And it worked! (FFS writes a new sync.ffs_db on the phone)

I thought I solved the MTP problem at least with the workaround of deleting sync.ffs_db on the phone just before starting syncing. But unfortunately it wasn't so because FFS also freezes in other cases:
I modified C.txt on PC, then I launched the comparison, then I deleted the database but on synchronization FFS freezed again.
Going to see the mobile folder I found the file C~8d18.ffs_tmp. The content was the same as C.txt in the PC folder. Instead the mobile C.txt file was gone.
What was FFS trying to do that it couldn't do? Renaming you can. Maybe change attributes? That in fact it is not possible manually from File Explorer.

In short, dear Zenju, now it's up to you. Please, tell me that everything I told makes no sense to you and I have to definitively give up or that FFS in a new version will manage these phone restrictions and makes the MTP synchronization finally possible.

Thank you.
User avatar
Posts: 3609
Joined: 11 Jun 2019

xCSxXenon

As in every other MTP thread, the issues persist outside FFS. It is a protocol issue, or an issue with the way the device handles MTP requests. Even without the database file in use, I still had sporadic issues. Run a system log while you run these tests and see where the freezes happen.
Posts: 12
Joined: 15 Sep 2018

Lyrus

Maybe I can do a simpler example to better explain myself.

Take a pair of folders to sync, one on PC and the other on Phone.
These folders are empty. (no database either)
Click 'Compare'.
FFS says: "No files to syncronize".
Click 'Synchronize' anyway.
FFS will write a database in each folder.
Put a file in the PC folder.
Click 'Compare'.
FFS produces the job list consisting in one line: copy file existing on PC to the Phone folder.

If you now click 'Synchronize' FFS will freeze while showing:
Saving file "mtp:\Galaxy S10 Lite\Phone\FolderOnPhone\sync.ffs_db"
and you need a sort of reset disconnectiong the phone that leads to a message popup saying:
Cannot move file
"mtp:\Galaxy S10 Lite\Phone\FolderOnPhone\sync.ffs_db.ac21.ffs_tmp" to
"mtp:\Galaxy S10 Lite\Phone\FolderOnPhone\sync.ffs_db".

If (after clicking 'Compare') you FIRST delete database on Phone and, AFTER that, you click 'Synchronize' FFS will do his job and at the end in phone folder will be the file AND also a database.

Obviously with a synchronization FFS needs to update the database (on both folders). So, in the first case it opens sync.ffs_db to modify it but can't save it because it's not allowed in MTP as I remembered in the first post.

In the second case sync.ffs_db is not present so FFS writes it from scratch.

So when MTP is involved in a synchronization FFS should simply delete sync.ffs_db and write a new one, not modify.

It's not an issue of MTP protocol. MTP is as it is (yes, rubbish). And can't be changed. Maybe FFS can do something to manage those restrictions instead of freezing.

Anyway my considerations are just an idea on what is happening during these operations. I do not pretend to have clearly understood the matter. For this reason I am really looking forward for Zenju to shed some light and read his comments.
User avatar
Posts: 3609
Joined: 11 Jun 2019

xCSxXenon

I thought I solved the MTP problem at least with the workaround of deleting sync.ffs_db on the phone just before starting syncing. But unfortunately it wasn't so because FFS also freezes in other cases:
I modified C.txt on PC, then I launched the comparison, then I deleted the database but on synchronization FFS freezed again.
You also said that deleting the db file didn't fix it with this scenarios either, so I am confused
Posts: 2
Joined: 30 Apr 2021

ToneM

I also have been wrestling with syncing through MTP to several phones over the years.

Finally, I've sussed it. It gets stuck on .nomedia files.

I had accumulated 11 .nomedia files scattered throughout my music library. I've now deleted them all from the local library and the phone, except for one in the library parent directory.

I now sync a subdirectory of the parent directory where the .nomedia file is. FFS now works fine and fast.

I thought I'd never get there, as I've hammered away at this problem a load of times then given up for the time being. Hopefully, this'll work for other users hitting the same brick wall.
User avatar
Posts: 3609
Joined: 11 Jun 2019

xCSxXenon

I had the issues and I don't have those .nomedia files.
They only way I got it to work reliably was using a USB 2.0 splitter and that is what my phone is plugged into
Posts: 12
Joined: 15 Sep 2018

Lyrus

You also said that deleting the db file didn't fix it with this scenarios either, so I am confused
Yes, in the other scenario there is a file to be updated (not just copied).
In this case here is what happens:

Image

I click 'Compare' and you can see in the job list that C.txt has to be updated on right side.
Than I delete the db on phone.
Than I click 'Synchronize'.
And FFS freeze while saying: Updating file "mtp:\Galaxy S10 Lite\Phone\FolderOnPhone\C.txt".
When I disconnect the phone the error message appears.
When I reconnect the phone I find in its folder the file: C~26d9.ffs_tmp (also named in the error message).
The content of this file is same of C.txt in the PC folder.

Sa as far as I understand FFS could have made a copy of C.txt of PC to the folder of phone with a temporary name C~26d9.ffs_tmp. Then deleted C.txt on phone and finally should have renamed C~26d9.ffs_tmp to C.txt but it failed (see in the error message: Cannot move file ....\C~26d9.ffs_tmp to ...\C.txt)
But you can rename files on phone. I can do it with file explorer. So even FFS can do it. So why it freezes?

I beleive that FFS is not doing what I said. Only Zenju knows which real operations is performing in this scenario.

But again, like modifying db file, FFS is doing something not allowed by MTP. Can it do differently?

What intrigues me is that the issue I experience seems different from others.
For me is not a problem of reliability. For me it NEVER works!

Just to know. Are you able to open with file explorer a text file on phone, modify it, and save?
From Wikipedia: "...It (MTP) does not support operations such as open, edit and modify."
Posts: 12
Joined: 15 Sep 2018

Lyrus

Want to see the specular scenario?

This time D.txt on phone is newer and file on PC needs to be updated:

Image

It works, as expected, because FFS have to do nothing on D.txt on phone.
Obviously, BEFORE clicking 'Synchronize', I deleted sync.ffs_db on phone.

If I DON'T DELETE db here is what happens:

Image

It freezes on updating the existing db on phone.
Posts: 6
Joined: 26 Oct 2017

alagga

For your Info. I suggest using USB Tethering and a FTP Connection.
This works way more reliable and even faster than MTP.

I've used FTP Server from Playstore to set this up. For smaller backups you could even sync using your Wifi network instead of the USB Tethering. However USB Tethering is way faster for me.
Posts: 12
Joined: 15 Sep 2018

Lyrus

Many thanks alagga for your suggestion.
I will try. I know nothing about FTP, so I have first to learn something about the matter.
But if it is a solution I will definitely try.
Thanks again.
Posts: 1
Joined: 8 Aug 2022

innocent546

For anyone else having this problem, You can try using FTP over a local network (Your home wifi router, USB tethering)

Possible example. For security, use this guide only on home networks.

1. Install an FTP app on phone - Install amaze file viewer (Free, lightweight, FTP available with a good file viewer)

--You can use one of the below 2 and 3 steps.
2. Connect the phone to the PC using USB -> Enable the "USB tethering" option in phone settings. (Usually faster)
3. Connect both phone and PC to the same router using wifi or cables. (Fast with a good router and a good phone)

4. Open FTP Server from your FTP app on your phone - Open the amaze app -> Open the left pane by clicking the menu icon on the top left corner -> Select "FTP Server"->
5. Configure FTP server settings -> Click the options icon on top right of the FTP server page of amaze app -> Disable secure connections, Read only access, etc... -> Click logins and disable anonymous login -> fill in some user detail (eg: username="abc", password="bcd")
6. Click start to start the FPS server. -> It should display an URL address like "URL - ftp://192.168.42.129" and a port (such as port- 21). It should be ftp instead of ftps. Otherwise, disable the "secure connections" option or any other advanced option.

7. Configure Free File Sync to use FTP -> click the cloud icon placed after the sync address bar and the browse button. -> Select FTP option from the top toolbar -> type in the details given in the FTP server app of the phone (Eg - IP = 192.168.42.129 , port=21, Username = "abc", Password = "bcd" )
8. Click browse below the "Directory on server:" field.

If everything went fine, a window will pop up and will let you select the folder you want to sync.

Make sure you recheck the details every time you change the connection. After changing any setting on the amaze app, try stopping and starting the FTP server again. You can also change the "shared path" of your phone in the amaze FTP server settings.

This is way more stable than MTP. With a good router, you can even do wireless transfers.