jb2170 / better-adb-sync

Completely rewritten adbsync with --exclude
Apache License 2.0
363 stars 23 forks source link

weird behavior, synced files not showing up in gallery/other apps without copying manually once #31

Open plutonium-239 opened 1 year ago

plutonium-239 commented 1 year ago

[Android 13, mostly Stock (ASUS)] I was getting a lot of random copying-stop errors in large manual file transfers (~8GB of photos/videos) so I used this tool. It worked wonderfully, not just faster but without any errors. However, I noticed that in my gallery, I could only see the files that I had manually copied, although in file explorers, I could confirm the files were there, taking the required space. I tried copying over other small folders and noticed the same result - only files copied manually would show up in any gallery apps (stock and third party), so something is definitely missing

Does android do some media files db stuff when files are manually copied over, which might be missing in this tool? Maybe these might be related: SO Link1 SO Link2

Any better fixes in the meantime?

jb2170 commented 1 year ago

Yeah I've noticed this too. I sometimes copy the folders over with adbsync and then rename them in a filemanager and then they show up in the gallery etc. I use OnePlus's file manager which I don't have the source code to but other file managers do the broadcast after copying a file eg this one: copy calls broadcast to rescan.

Looks like there's a way to send a broadcast from the command line via adb shell as suggested on SO. I'll have a look at adding that so that adbsync calls this after the transfer is done to rescan the destination file / folder.

jb2170 commented 1 year ago

Looks like the broadcasting method is obsolete and requires MediaScannerConnection.scanFile. I'm not sure if there's an easy way to do that from the command line?

plutonium-239 commented 1 year ago

Hey! Thanks for looking into it. In the meantime, I found a way to do this, there are many "Media Rescan" apps on the play store which just rebuild, and I found these two worked for me: https://play.google.com/store/apps/details?id=com.rasenstudio.mediarescan - entire device, no options https://play.google.com/store/apps/details?id=awais.media.scanner - has folder selection as well

I'll also look for ways to do it via the cli

milchalpenl commented 1 year ago

adb shell am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file:///storage/emulated/0/ > /dev/null 2>&1 Edit sorry.