nextcloud / android

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

Upload of locally changed files #757

Closed christianhauff closed 5 years ago

christianhauff commented 7 years ago

If I change e.g. a text file with an external editor, the file won't be updated in the cloud, also after several edits and app-restarts! It only works if I select the file and synchronize it manually! I think this has already been working in the last stable version!

Expected Behavior

NC shoud automatically recognize changes in the local folder and upload them instantly

System: Samsung S5, Android 4.4, current NC app from Play Store

AndyScherzinger commented 7 years ago

Did you mark the file as available offline in the Nextcloud Android app?

PaulFreund commented 7 years ago

I noticed this too, all (PDF) files I open from nextcloud are copied to the download folder and opened from there. It does not matter if the file is synchronized (available on the device), marked as available offline or online. Tested with NextCloud 1.4.2 app on a Nexus 5X (Android 7.1.1)

AndyScherzinger commented 7 years ago

copied to the download folder and opened from there

Do you mean the data folder of Nextcloud or the phone's actual download folder? If the file is opened from within the Nextcloud app referring to another app (tried it with a Word document then edited in Google docs app) and eg a Word doc I just tested with NextCloud 1.4.2 app on a One Plus 3 T (Android 7.1.1) file being marked as "available offline" works just fine.

christianhauff commented 7 years ago

in my case, I am talking about the NC cache folder, but the procedure is the following: I have a file which is not available offline, click on the file in the NC-App, it is beeing downloaded, in the action menu, I press on "Open with" and select an Editor (e.g. DroidEdit). The editor openes, I change something, save it and return to the NC-App, but nothing happenes.

Same issue with a PDF-Document.

So we are not talking about the phone's download folder of course, just the NC-Caching folder!

spectas commented 7 years ago

Hi everybody!

I would suggest the same thing. I already lost a file because of the missing auto-sync function. I am not an Android expert. But when opening a file for editing (no matter in what program), maybe a watch dog process should be started to track the changes. Afterwards, it could upload the changes automatically to the server. Imho there should not be a difference between marked / not marked as offline available. I can't expect sombody editing an online file and not wanting it to be synced afterwards. At least there should be a warning: "File has been updated. Do you want to sync it to the server?"

Thanks a lot!

AndyScherzinger commented 7 years ago

@christianh95 the download folder question came due to @PaulFreund's comment plus combined with your comment, some remarks: The Nextcloud app downloads the files to the app's data folder, Thumbnails are put into Nextcloud's cache folder (no copying here or anywhere...). So if a file is marked as "available offline" and edited then it should be synced back to the server (or this is a bug even in today's implementation)

@spectas @christianh95 I understand your request and also think all files which made it down to the app's/device's storage should always be kept in sync, but unfortunately it is way trickier than you think as you are requesting this feature about which I already had discussions with @jancborchardt and @eppfel

Any input or suggestions anyone on how to handle these situations? (Obviously I would like to make everyone happy!) 😄

christianhauff commented 7 years ago

I am a very beginner on android development, but shouldn't it be possible to apply a FileObserver event handler on all (or selected) files in the app's data folder to monitor changes and upload them again in the background? If I compare it with the Dropbox-app (that I want to get rid of), the files are instantly uploaded on every external change, no matter if you are in cellular of wifi! That's the behavior I would expect, maybe even with a possibility to configure the behavior on cellular/wifi individually.

mario commented 7 years ago

a) Instant upload isn't a reality anymore after the changes done with the platform b) FileObserver is fundamentally flawed as it relies on inotify which is broken on many phones and vendors c) Ideally, full sync will be done via a Sync Adapter anyway and it's focus won't be on "instant upload" or speed, but on reliability

AndyScherzinger commented 7 years ago

@christianh95 commenting on dropbox I have to disappoint you: it doesn't anymore, your phone OS might just be too old, the issue is that this "instant behavior" has been forbidden/prevented on newer Android version and started with 6 and has gotten way more restrictive with 7 :( That is also the reason why we implemented auto upload since the former instant upload won't even work anymore under Android 7 since scheduling work now needs to be done by Android itself...

PaulFreund commented 7 years ago

@AndyScherzinger thank you very much for your considerations.

Current behaviour:

Proposed behaviour:

I think the indexing frequency does not need to be very high as long as the user has a way to see the current status and maybe trigger a direct index and sync.

varac commented 5 years ago

Hope this is the right issue to add my experience:

When changing a file locally on my device, i.e. using a text editor, nextcloud app won't notice this until I start the nextcloud app and navigate to the folder where the file is located in. I'm using "make file offline available" (sorry for bad translation from german), it doesn't make any difference to not marking it offline available.

Details: nextcloud app 3.4.1, on a Samsung gaalxy S5 with linageos 15.1.

Use case is i.e. https://github.com/mpcjanssen/simpletask-android/, an app which saves tasks to a local text file.

varac commented 5 years ago

2395 is possibly related

tobiasKaminsky commented 5 years ago

@varac with next version all downloaded files will synced every 15min when on wifi.

We cannot detect a change of a local file correctly. E.g. if we use a change listener, when do we want to sync? After each sync? Imagine you write a text and save after each sentence.

Maybe you want to use https://play.google.com/store/apps/details?id=nl.mpcjanssen.simpletask.nextcloud instead?

varac commented 5 years ago

@varac with next version all downloaded files will synced every 15min when on wifi.

Ok, nice!

We cannot detect a change of a local file correctly. E.g. if we use a change listener, when do we want to sync? After each sync? Imagine you write a text and save after each sentence.

Well, same for the desktop client right ? It does watch for changes and uploads them on every change, no matter how often you save the file. Why should nextcloud-android behave differently ?

Maybe you want to use https://play.google.com/store/apps/details?id=nl.mpcjanssen.simpletask.nextcloud instead?

I'm using simpletask nextcloud from f-dorid already (built from https://github.com/mpcjanssen/simpletask-android).

tobiasKaminsky commented 5 years ago

Well, same for the desktop client right ? It does watch for changes and uploads them on every change, no matter how often you save the file. Why should nextcloud-android behave differently ?

Desktop is not using a file/change listener, instead the just start a sync process every 30s. So basically they are doing the same as we on Android (but we have a bit longer timespan).

yokowasis commented 5 years ago

Well, same for the desktop client right ? It does watch for changes and uploads them on every change, no matter how often you save the file. Why should nextcloud-android behave differently ?

Desktop is not using a file/change listener, instead the just start a sync process every 30s. So basically they are doing the same as we on Android (but we have a bit longer timespan).

I don't buy this. in Desktop (Windows) the change is synced (uploaded) automatically upon save. Not based on interval. It behaves the same way as Google Drive and Onedrive. It detect on file changes.

varac commented 5 years ago

Well, same for the desktop client right ? It does watch for changes and uploads them on every change, no matter how often you save the file. Why should nextcloud-android behave differently ?

Desktop is not using a file/change listener, instead the just start a sync process every 30s. So basically they are doing the same as we on Android (but we have a bit longer timespan).

I don't buy this. in Desktop (Windows) the change is synced (uploaded) automatically upon save. Not based on interval. It behaves the same way as Google Drive and Onedrive. It detect on file changes.

Ineed. I just did a simple test:

 ~/Nextcloud | date; touch test.txt                                         
Fr 18. Jan 18:35:26 CET 2019

Nextcloud client notices in the same seconds and triggers a sync:

Jan 18 18:35:26 [OCC::FolderWatcher::changeDetected     Detected changes in paths: QSet("/home/varac/Nextcloud/test.txt")
…
varac commented 5 years ago

So I still propose to not deviate from this nice behaviour and do the same on Android: watch the dir(s) and sync on changes, not on intervals.

yokowasis commented 5 years ago

I am beginning to think that it isn't possible in Android. I can't find any software that can sync on changes on Android.

PaulFreund commented 5 years ago

I am beginning to think that it isn't possible in Android. I can't find any software that can sync on changes on Android.

While not trivial to implement in an efficient way that runs in the background without using up too many ressources the API does offer the required facilities (https://developer.android.com/reference/android/os/FileObserver). Regarding the best time of sync I'd say this could be handled by a downtimer that waits a certain amount of time until uploading thus preventing trigger happy applications saving all the time to cause a sync every time. For example on every write to a file observed a timer for one minute is started and if this timer goes to zero the file is actively synced. In case the file gets written again the time will be reset to one minute.

Of course this is only the local part, we still need a timer that regularly asks the nextcloud server for changes and syncs them in the other direction.

christianhauff commented 5 years ago

As we are talking about file system listeners or "search for changes in an interval", would it be an option to search for changes when you opened a file out of your nextcloud app with an external editor and then return to nextcloud after you closed the external editor? Is that an event that can be detected?

yokowasis commented 5 years ago

As we are talking about file system listeners or "search for changes in an interval", would it be an option to search for changes when you opened a file out of your nextcloud app with an external editor and then return to nextcloud after you closed the external editor? Is that an event that can be detected?

You can already do that. Although maybe not all text editor. But I can edit file on the fly using quickedit (but not droidedit). When I save, it is immediately uploaded into nextcloud. The same behavior applied into other cloud app, e.g. One Drive, Google Drive.

tobiasKaminsky commented 5 years ago

Nextcloud client notices in the same seconds and triggers a sync:

Then I got this wrong somehow. I guess it is the other way around, if you change something on the server, this change is polled every 30s. Sorry for that.

Regarding FileObserver: I cannot find it, but I recall that there is a limit of watched files…

christianhauff commented 5 years ago

You can already do that. Although maybe not all text editor. But I can edit file on the fly using quickedit (but not droidedit). When I save, it is immediately uploaded into nextcloud. The same behavior applied into other cloud app, e.g. One Drive, Google Drive.

The only text editor I use is droidedit, that's why I haven't experienced that behavior so far. But why is that editor dependent? Isn't it possible to check the return from any app, may it be a text editor, a pdf editor or whatever?

yokowasis commented 5 years ago

You can already do that. Although maybe not all text editor. But I can edit file on the fly using quickedit (but not droidedit). When I save, it is immediately uploaded into nextcloud. The same behavior applied into other cloud app, e.g. One Drive, Google Drive.

The only text editor I use is droidedit, that's why I haven't experienced that behavior so far. But why is that editor dependent? Isn't it possible to check the return from any app, may it be a text editor, a pdf editor or whatever?

Probably because droidedit doesn't implement those features. When I am using Quickedit, it just works. Whether it's from Google Drive, Onedrive, Nextcloud. I think it has something to do with Android API or something.

As of right now, this is our best option. You still can't add new files though.

tobiasKaminsky commented 5 years ago

With next version, the doc provider is enhanced, so that you can also create new files.

unix0r commented 5 years ago

What about the WorkManager API of Android? https://developer.android.com/topic/libraries/architecture/workmanager

The documentation says: WorkManager is intended for ... Periodically syncing application data with a server.

Sounds pretty good? Somehow I can't believe, that there is no way to synchronize an app with its server in Android in a way we would like to have it.

stale[bot] commented 5 years ago

This request did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

christianhauff commented 5 years ago

Isn't it possible to get this running editor-independent? So any time the user returns from any editor app (text-editor, pdf-viewer, etc.), it checks if the file was changed and uploads it? When I manually press the Synchronize-Button after returning from my editor, it works all fine! When there was no change and I press synchronize, nothing happenes, so there is definately a check whether the file was changed. Can we call that check anytime we return to ne nextcloud-app?

yhtang commented 5 years ago

I noticed this too, all (PDF) files I open from nextcloud are copied to the download folder and opened from there. It does not matter if the file is synchronized (available on the device), marked as available offline or online. Tested with NextCloud 1.4.2 app on a Nexus 5X (Android 7.1.1)

It is still the case with the Nextcloud Android app 3.6.1 on Android 9, with a v15 server. Is there any way to work around this?

stale[bot] commented 5 years ago

This request did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

mbrgm commented 5 years ago

Well, closing the issue won't make the problem go away.

stale[bot] commented 5 years ago

This request did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

Styx13 commented 2 years ago

Hello here.

This issue is still happening for me on Android 12, Nexcloud Android Client 3.21.2 and Nextcloud Server 24.0.2

Any new plans to detect changes on android?

RockWest commented 1 year ago

I have also been experiencing this issue for years, and I find it frustrating to have to manually sync when files changes, and leads to having to manually merge different versions of my notes countless times.

Currently running Android Client 3.25.0 and Server 27.0. However it has been the same for a dozen versions before that as well.

superzanti commented 2 months ago

A year later, I'm also wanting this feature.

I have some notes that I like being synced between my phone, computer, and nextcloud server. But if I change stuff on my phone I have to manually sync it up.

AndyScherzinger commented 2 months ago

2way sync is currently being implemented by @tobiasKaminsky

Sorry for the long wait but folks are on it, as in really on it as there is already a work in progress Pull Request / implementation.

mnalis commented 2 months ago

2way sync is currently being implemented by @tobiasKaminsky

pabloeisenhut commented 2 months ago

2way sync is currently being implemented by @tobiasKaminsky

Sorry for the long wait but folks are on it, as in really on it as there is already a work in progress Pull Request / implementation.

Very nice! Are there any plans to implement this function (https://github.com/nextcloud/ios/issues/2670) in the iOS app as well?