nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.23k stars 1.76k forks source link

Auto Upload with "Moved to App Folder" temporarily disappear from android gallery #10373

Open duanenewman opened 2 years ago

duanenewman commented 2 years ago

Steps to reproduce

  1. Setup auto upload on Camera folder with "Original File will be..." set to "moved to app folder"
  2. Take a picture
  3. Wait for the auto upload to run and move the picture
  4. Image disappears from Gallery app
  5. After a while (overnight) or after rebooting the phone the image shows up.

Expected behaviour

Auto uploaded images should still be visible to android gallery without need to reboot or wait for gallery to run media scanning process. This used to work as expected.

Actual behaviour

Auto uploaded images disappear from gallery and will not show up (even though present if viewed with file explorer tools) until some time has passed or the phone is rebooted. The photos are also not visible to other apps (Facebook, instagram, email, etc) until the reboot or regular scan happens.

Environment data

Android version: 12

Device model: SM-G988U (Samsung Galaxy S20 Ultra 5G)

Stock or customized system: stock

Nextcloud app version: 3.20.2

Nextcloud server version: 23.0.2

This is especially painful when I've taken a lot of pictures at an event or traveling and want to make a post to share pictures and I have to reboot to get the images available. I have found a workaround to be setting my phone to only upload while charging so it at least delays it long enough that I can use the picture, but that is not idea either.

I looked for this in the issues but everything was around the feature not working. I found a post on the nextcloud help forum from 2020 that was never replied to with the exact same behavior noted: https://help.nextcloud.com/t/syncing-pictures-and-videos/100116

AlvaroBrey commented 2 years ago

This is known behaviour on Android 11+ as the system won't let us add media to the MediaScanner if it is on a private app directory; this issue was hand-in-hand with #9328 , there has been a lot of discussion there. The only real solution to this is to allow using Downloads as the download location for Nextcloud.

I am surprised, however, that the pictures show up after a while. Can you check the details on any of them from the gallery? As in, where are they stored, etc?

duanenewman commented 2 years ago

Thanks @AlvaroBrey, I searched the issues but didn't see that one. Yes, the images show up immediately on reboot, or after some time period (i.e. overnight, when I'm assuming the mediascanner runs again).. Also, OneDrive detects the new media file location pretty much right away asks if I want to add it to my uploads (although strangely the message OneDrive shows says it found a new media file location, directory, that has the same name as the image).

Here is the info for one I took yesterday that uploaded and shows up today in the gallery app:

NextcloudFolderPicture-cropped

AlvaroBrey commented 2 years ago

although strangely the message OneDrive shows says it found a new media file location, directory, that has the same name as the image

Yep, that is the (invalid) folder referenced in #9328. Today 3.20.3 is going to release, which fixes the (invalid) folder bug, but does not fix media not being scanned. If you don't mind, can you report back when you have the update, so we can see if the behaviour has changed at all?

duanenewman commented 2 years ago

If you don't mind, can you report back when you have the update, so we can see if the behaviour has changed at all?

Yeah, I can do that.

duanenewman commented 2 years ago

That build did seem to fix the issue with the onedrive error message. I'll note it on the ticket #9328 as well.

DragonQ commented 2 years ago

Same issue here although it only started after upgrading my Samsung G9700 to Android 12. It makes the auto upload feature essentially useless because I can't see anything uploaded until the following day.

Surely there must be a way around this?

AlvaroBrey commented 2 years ago

Surely there must be a way around this?

Currently the only way is to not use "Move to nextcloud folder" as an autoupload behaviour. That way the files will be left in the original folder.

You also should be able to browse the files in Nextcloud through your default file browser.

DragonQ commented 2 years ago

Currently the only way is to not use "Move to nextcloud folder" as an autoupload behaviour. That way the files will be left in the original folder.

This won't work for my workflow. When I take a photo it gets dumped in my DCIM folder by my camera app. I then choose photos for a particular category and move them to a "staging" directory. Nextcloud then uploads from this staging directory to an appropriate folder on Nextcloud, into subfolders based on year/month.

Putting the files directly into the correct Nextcloud folder is problematic for a few reasons. Firstly, it would take a while to find the Nextcloud data folder since it's quite far down the directory tree. Secondly, I'd have to manually find the year/month subdirectory. Thirdly, I'd have to set all of those subdirectories to have auto-upload configured, which will be a nightmare and need multiple manual updates every month.

You also should be able to browse the files in Nextcloud through your default file browser.

True but not being able to use a gallery app defeats the purpose of having a cloud solution for photos.

The "best" workaround I've found is to run the AZ MediaScanner application after Nextcloud has finished uploading. This does take several minutes though so is not ideal either. It's amazing to me that Google keeps making Android less and less usable with each major version. With Android 11 all of this used to work fine (from an Android perspective at least; there were often bugs with the Nextcloud app).

svenb1234 commented 2 years ago

Could this have been fixed with 3.21.1?

svenb1234 commented 2 years ago

And it is broken again with 3.21.2. so does this depend on the API Level?

iamLazyCode commented 2 years ago

Any updates on fix to this yet ?

AlvaroBrey commented 2 years ago

And it is broken again with 3.21.2. so does this depend on the API Level?

It shouldn't, but the Android ecosystem is somewhat unpredictable in what it does vs what it should do. We're planning to bump the API level back up as soon as #10737 is done, so we'll see.

iamLazyCode commented 2 years ago

And it is broken again with 3.21.2. so does this depend on the API Level?

It shouldn't, but the Android ecosystem is somewhat unpredictable in what it does vs what it should do. We're planning to bump the API level back up as soon as #10737 is done, so we'll see.

please do fix , this single thing will eliminate all the issue i have remaining with nextcloud

rigibe commented 2 years ago

Coming back again to this issue, I have tried to manually move the pictures with a file explorer (I use Total Commander) to /Android/media/com.nextcloud.client/nextcloud/user@next.cloud/InstantUpload/Pics. The pictures are immediately recognized by the gallery app (I use Google Photos). So, it seems that T.C. updates the Media Store in a proper way. I also tried to let the Nextcloud app moving the files in the InstantUpload folder. Then I manually cut these files outside and back into the folder. In this way, the pictures are seen by Google Photos.

Why coudln't nextcloud just do the same?

jobec commented 1 year ago

I don't know much about android apps, but when I looked into it, I stumbled on this:

https://developer.android.com/reference/android/media/MediaScannerConnection#scanFile(java.lang.String,%20java.lang.String)

Referenced in the example here (although that function seems deprecated, the example looks still valid): https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory%28java.lang.String%29

Isn't that what the Nextcloud client should be doing? I don't find such piece of code anywhere in the code here on github.

DragonQ commented 1 year ago

I don't know much about android apps, but when I looked into it, I stumbled on this:

https://developer.android.com/reference/android/media/MediaScannerConnection#scanFile(java.lang.String,%20java.lang.String)

Referenced in the example here (although that function seems deprecated, the example looks still valid): https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory%28java.lang.String%29

Isn't that what the Nextcloud client should be doing? I don't find such piece of code anywhere in the code here on github.

I don't know specifics but this is 100% a Nextcloud app issue. If I move files using other apps, I immediately see a "media scan" popup and the files appear immediately in other apps (e.g. gallery). Never happens with Nextcloud.

disgustipated commented 1 year ago

My workflow for this is to edit photos in Lightroom on my desktop pc, let them sync to NC and then on my phone upload them to whatever app i want. to get them to show up i have to reboot the phone, way back around android 6 this used to be a common issue with apps and i was able to trigger a media scan manually in dev tools but looks like that has been moved and i cant seem to find it.