desktop icon indicating copy to clipboard operation
desktop copied to clipboard

Stop Sync on mobile connection

Open goddib opened this issue 7 years ago • 36 comments

Hi everyone, I am using the windows desktop client with several nextcloud instances so there is a lot of synching going on. At the same time I'm on the move a lot and use a mobile connection to stay in touch. It would be great if I was able to deactivate snyching when on metered connections (since Windows allows for categorization of such). What do you think?

Cheers, goddib

goddib avatar Nov 16 '17 08:11 goddib

related: https://github.com/nextcloud/client/issues/27

michaelstingl avatar Nov 16 '17 14:11 michaelstingl

Why is this marked as discussion and not as feature request? It is already implemented in the Android client: https://github.com/nextcloud/android/issues/154 Actually this is not only interesting for Windows users. I'd be glad if it would be possible with Linux, too. I use my computer at home and at work. The latter has a metered internet connection, so I'd like to forbid nextcloud there and resume sync at home automatically.

keinstein avatar Jan 03 '19 14:01 keinstein

I suppose not many people find this the most important thing to add, which I do understand. At the same time it seems like metered connections are here to stay for a while - mobile as well as WiFi connections. Even Microsoft has accepted that and has the "metered" functionality integrated deep into Windows 10. So I believe that it would be a useful feature to add - maybe we should discuss this as a "feature request" to get to a decision more quickly? In the meantime I resorted to using the commercial tool "TripMode" to stop nextcloud from synching for lack of open source options.

goddib avatar Jan 06 '19 15:01 goddib

Would be the same for me - as I'm using my mobile quite often for data. I'd be very thankful not to be forced to rather switsch sync off, every time or switch syn on on the other hand.

RGina666 avatar Feb 05 '19 18:02 RGina666

NetworkManager provides information if the current connection is metered (see https://people.freedesktop.org/~lkundrak/nm-docs/nm-dbus-types.html#NMMetered) so IMO this feature may be useful on Linux, too.

unixfox avatar Apr 29 '19 14:04 unixfox

Any News about this Request?

Happyfeet01 avatar Aug 10 '19 16:08 Happyfeet01

Same problem. I miss it so desperately! Nextcloud eats up mobile plan when connected via hotspot. This is a so basic requirement, that lacking of is already a bug...

Schleichmichl avatar Oct 01 '19 12:10 Schleichmichl

The definition of a bug is "feature that does not work as expected". The feature is not there yet, therefore is not a bug but a feature request. The priority of implementing it is also up for debate.

camilasan avatar Oct 01 '19 12:10 camilasan

Yeah, you are so right :-) But where can I vote for this feature request or at least create it?

Schleichmichl avatar Oct 01 '19 12:10 Schleichmichl

I would say you need keep this issue 'alived' by commenting here, but I would expect that this issue should not be a problem anymore with the Virtual Drive and with the pull request #1453. What do you think?

camilasan avatar Oct 01 '19 12:10 camilasan

unfortunately limiting in terms of time is not really useful for my problem, as I'm using mobile internet unregularly in a mix with "normal" WLAN. Would be great, as Onedrive an co can do, to link it to the network status....

Thanks for all your work :)

RGina666 avatar Oct 02 '19 10:10 RGina666

I follow up on RGina666. The scheduling has totally different use cases.

As usage of the wifi connection is not bound to a given time, the worst case could be to sync just in that time where wifi is used. That would then worsen the data usage, as files are synced that would have been synced already when not using the scheduler.

Schleichmichl avatar Oct 03 '19 06:10 Schleichmichl

A good place for this option could be the scheduler menu. In C# the function to get the connection type is GetConnectionCost.

esguti avatar Oct 03 '19 07:10 esguti

Same here, for me this is a vital feature. Had my nexcloud client eat up my whole plan for the month several times while on the way before noticing. Dropbox, spideroak, etc adhere to the metered connection. Now, I am manually pausing sync before connecting to my mobile hotspot. Whenever I forget however, I am going without mobile internet for the month... Hope you can get around to implementing this on windows, and keep up the great work, nextclud is a perfect project for everyone wanting to keep control over their data, I have really come to love it! :D

Ageraluon avatar Jan 18 '20 22:01 Ageraluon

For me also helpful feature. Specially when OneDrive pops up to ask and nextcloud not.

cscholz avatar Apr 24 '20 06:04 cscholz

the issue is still there with WIndows Desktop client 3.0.2 - it syncs while OneDrive and Google Drive pause syncing on mobile network. Please add an option to pause on metered connection (should pause by default) to avoid exceeding mobile plan by sync client.

isdnfan avatar Oct 12 '20 08:10 isdnfan

My data plan was also eaten up several times. I paused it once I was on metered connection but forgot it to reactivate at home. Then I needed up to date files on the road again and had to sync, which was quite expensive. I hope it is moving up in the backlog. The new UI brings definitely less value than this highly reasonable feature.

Schleichmichl avatar Oct 12 '20 08:10 Schleichmichl

I've been looking to see this functionality added too. Even if it isn't about mobile data limits, it can be an unnecessary bandwidth hog and battery drain while on a mobile hotspot.

lzs avatar Oct 29 '20 23:10 lzs

As a VPN RoadWarrior I am often "on the road" and sometimes I edit files or others change shared folders which (of course) forces my local client to update the local repo. Is this really that hard to implement?

if network = metered connection { pause sync }

OneDrive is able to notice that, GoogleDrive not. But the reason to switch to Nextcloud is obviously because it is way better than those other clouds and I want it to stay better.

DaniW42 avatar Jan 17 '21 12:01 DaniW42

+1

talentpierre avatar Jan 17 '21 13:01 talentpierre

+1. Using my mobile as a hotspot and my data gets eaten up due to this issue.

Backes89 avatar Feb 09 '21 14:02 Backes89

+1 Urgent

Wildside007 avatar Mar 11 '21 15:03 Wildside007

This is so urgent. Not included in Client Version 3.2.2. :-( As other users already said, it can be considered as basic functionality. Please compare to other cloud clients!

To relief the PO here is a ready to pull user story: I as a user want to decide if nextcloud is syncing on metered connections in order to avoid expensive, unplanned, disruptive negative effects on the data plan.

Acceptance criteria: -Checkbox in one of the setting pages (Network) to forbid sync on a metered connection. -Sync does not start when on metered connection -Sync starts when connected to a flat connection

Streched goal: Additional checkbox on setting page setting (Ask the user) and popup that ask user "Sync" / "don't sync" when detecting metered connection (like OneDrive)

Schleichmichl avatar Jun 04 '21 08:06 Schleichmichl

+1. Using my mobile as a hotspot and my data gets eaten up due to this issue.

Maybe i am stupid but I just not see how the desktop client can know that for example my mobile data connection is free to use (even if metered) but yours is not.

Do you somehow give the information to your operating system ?

mgallien avatar Jun 07 '21 09:06 mgallien

+1. Using my mobile as a hotspot and my data gets eaten up due to this issue.

Maybe i am stupid but I just not see how the desktop client can know that for example my mobile data connection is free to use (even if metered) but yours is not.

Do you somehow give the information to your operating system ?

In windows you just define connection as "metered" and with that general setting should easily be able to switch sync in nextcloud on or off.

RGina666 avatar Jun 07 '21 10:06 RGina666

As well as setting the metered status of connections manually (which you can do in Linux as well, in the UI), some networks implement the MS-NCT extension to 802.11 to support propagating this information from the network to clients automatically. The OS will use this information automatically if available (Nextcloud won’t need to worry about implementing it).

pwithnall avatar Jun 07 '21 10:06 pwithnall

@RGina666 @pwithnall Thanks for the clarification

I guess I now understand the use case and how you expect to use it

I modified the tags such that we have it on our list of things to do but I cannot give any timeline. sorry for that my best hope would be that somebody from community does it

mgallien avatar Jun 08 '21 07:06 mgallien

there is a similar request to pause sync on battery #2284 - maybe it's worth to discuss all the conditions which are expected to pause the sync (battery, metered connection, specific times) and find an approach to improve all this areas at once?

isdnfan avatar Nov 07 '21 20:11 isdnfan

This would be very useful in Linux mobile devices like the pinephone. I have been using a pinephone with mobian Linux distribution and nextcloud can easily eat my monthly plan if not being careful. I believe that using the Network Manager DBUS API one can know whether the connection is metered or not (https://developer-old.gnome.org/NetworkManager/stable/nm-dbus-types.html#NMActiveConnectionState).

cquike avatar Sep 01 '22 22:09 cquike

For Linux, I created a NM script (that is run by NM on connection changes) that automatically pauses and unpauses Nextcloud sync based on the metered flag of connections. I wanted to quickly write a simple script, but things became somewhat more complicated quickly, but it does seem to work rather well now. Anyway, here's the script, see the top comments for how it works and how to install it:

#!/bin/sh -e

# This script will:

#  - Pause nextcloud sync when a metered connection was brought up (even when
#    it is not the default connection - better safe and simple than sorry).
#  - Unpause nextcloud sync when any connection was brought down and no
#    other connections are metered, but only if this script actually paused
#    nextcloud before (to prevent unpausing when you manually paused).
#
# This currently only works for a single, hardcoded user, which works for the
# typical single-user computer case. Multiple/different users could be
# supported by iterating over `loginctl list-users -o json` maybe.
#
# To use this script, save it as e.g.
# /etc/NetworkManager/dispatcher.d/99-nextcloud-pause and make it executable.
#
# Figuring out the metered status using nmcli was inspired by https://stackoverflow.com/questions/43228973/
# Queries and toggling nextcloud sync using dbus was inspired by https://github.com/nextcloud/desktop/issues/336#issuecomment-1100792690
# Running commands inside the user's dbus was inspired by https://stackoverflow.com/a/36873823/740048 

IFNAME="$1"
ACTION="$2"

# The user whose nextcloud to pause. For a more generic solution that works
# with all logged in users, `loginctl list-users -o json` could be used
NEXTCLOUD_USER=matthijs
PAUSED_BY_US="$RUNDIR/nextcloud-paused-by-nm-script"

if [ "$ACTION" != "up" -a "$ACTION" != "down" ]; then
	exit 0
fi

case "$ACTION" in
	up)
		# This checks the metered status of the connection *and* the
		# device. It seems that the connection status is manually set,
		# but can be unknown, while the device status can also be
		# guessed (i.e. for bluetooth connections it seems it is
		# unknown for the connection by default, but then is yes for
		# the device after connecting.
		if ! nmcli -t -f connection.metered connection show "$CONNECTION_UUID" | grep '^connection.metered:yes' > /dev/null \
		&& ! nmcli -t -f GENERAL.METERED dev show | grep '^GENERAL.METERED:yes' > /dev/null; then
			# New connection is not metered, nothing to do
			exit 0;
		fi

		pause=true
		;;
	down)
		if [ ! -f "$PAUSED_BY_US" ]; then
			# If we did not pause nextcloud, also do not unpause it
			exit 0
		fi

		# This uses device list instead of (active) connection listing,
		# since the latter does not seem to want to print metered
		# status (only when printing a single connection)
		if nmcli -t -f GENERAL.METERED dev show | grep '^GENERAL.METERED:yes' > /dev/null; then
			# Another metered connection still active, do not unpause
			exit 0
		fi

		pause=false
		;;
esac
	
# This uses systemd-run to run a command inside the user's session, to get access to the user's dbus
GDBUS_BASE_CMD="systemd-run --quiet --pipe --wait --user --machine [email protected] -- gdbus call --session --dest=com.nextcloudgmbh.Nextcloud --object-path /com/nextcloudgmbh/Nextcloud/Folder/0"

# Query current pause status
if $GDBUS_BASE_CMD --method org.gtk.Actions.Describe pause | grep -qF '[<true>]' > /dev/null; then
	currently_paused=true
else
	currently_paused=false
fi

# Toggle pause if necessary
if [ "$pause" != "$currently_paused" ]; then
	$GDBUS_BASE_CMD --method org.gtk.Actions.Activate pause '[]' '{}'
	if [ "$pause" = true ]; then
		touch "$PAUSED_BY_US"
	else
		rm -f "$PAUSED_BY_US"
	fi
fi

matthijskooijman avatar Oct 09 '22 15:10 matthijskooijman