nextcloud / files_texteditor

:page_facing_up: Text editor for plaintext files
72 stars 41 forks source link

Make autosave timer configurable #30

Open sehucke opened 7 years ago

sehucke commented 7 years ago

It would be great if one could adjust the autosave timer to his own needs.

One problem I ran into was that my version history got spammed with the default 5 s autosave mode. I have not tested that yet but I assume editing large documents when on a mobile network won't be fun either - especially when you only have a limited amount of monthly traffic available.

I would suggest following options:

The options could be set directly in the text editor next to the file name and saved as a per-user settings.

Any thoughts?

lukasb314 commented 7 years ago

I agree.

Compared to OwnCloud (which I have used until like 4 weeks ago), the autosave timer on Nextcloud seems to be set to a ridiculous low value.

When is the autosave being triggered?

It seems like it is triggered at every key strike, right?

Because when I edit a text file, I get a looong list of errors in my log file, saying like "File is modified since opening". So, I guess, what happens is that when I strike a key, the editor autosaves the document. When I strike the next key (within fractions of seconds) the editor wants to autosave again, but it hasn't finished autosaving from the previous key strike. This causes the errors. I can also see in the header of the editor that the autosaving happens permanently and occasionally some errors show up saying like "file is locked" or something...

I think this should be changed in general.

I believe, the way it worked on OwnCloud was that there was a time offset between the last key strike and the autosave trigger. Like wait 2 seconds after the last key strike, the autosave has been triggered. I think this was a good approach.

sehucke commented 7 years ago

When is the autosave being triggered?

According to the source code: AutoSave is triggered 3 seconds after the last change event.

It seems like it is triggered at every key strike, right?

As far as I understand the code: Yes and no. :-) (See below)

I believe, the way it worked on OwnCloud was that there was a time offset between the last key strike and the autosave trigger. Like wait 2 seconds after the last key strike, the autosave has been triggered. I think this was a good approach.

Works currently the same way here. Each change event in the editor resets the autosave timer to 3 seconds. But I doubt this is a good approach in the context of Nextcloud (and Owncloud either). It would mean you have to keep constantly typing to avoid autosave. Otherwise...

  1. your version history gets spammed (and so does your storage space)
  2. and the file is transferred to the server each time.

This is bad in multiple ways:

  1. Maintenance job scripts have to clean up a lot of files. It could lead to a huge pile of delayed jobs if you have set up your instance to run a job every time a web page is called (instead of using cronjobs).
  2. It is harder to find a relevant old version if there are hundreds or thousands of them.
  3. You might reach your data limit much sooner when working via cell phone networks.
  4. If you use backup automation scripts they have to process many small files. Especially when it comes to a larger user base.

Think of a "larger" file of 500k and a period of 30 minutes of work. And you are slow at typing or making a huge amount of small changes (e.g. lecturing a LaTeX file whilst on a train). Now assume autosave is called 5 times a minute over a period of 30 minutes. This would lead to 150 new versions and approx. 75 MiB of unnecessary data. Things can get even worse if the file is larger, if you use the app longer or if you make more small changes (up to 20 new versions each minute).

@tomneedham , @icewind1991 : You were the last who altered the relevant autosave functionality: Any thoughts on this?

lukasb314 commented 7 years ago

Works currently the same way here. Each change event in the editor resets the autosave timer to 3 seconds.

No, it does not. In my case it saves the file (or tries to save the file) immediately after each key strike. And this causes many errors, as described.

Well, do be more accurate: The 3-seconds autosave timer works as intended until the first autosave event after opening the file. Then it starts acting odd, as described before.

Tested two NC installations (11.0.3 and 12.0) and two different browsers - same issue everywhere.

Rocreex commented 7 years ago

I can confirm this and find this to be a huge issue that needs to be fixed quickly. Honestly, even if it worked properly, an autosave every 3 seconds would be too much in my opinion. The version history loses its purpose when you save a new version every 3 seconds. So in my opinion autosave should be disabled by default and only when closing the editor, the file should be saved.

lukasb314 commented 7 years ago

Just saw that there is already an open issue on the auto-save bug:

https://github.com/nextcloud/files_texteditor/issues/23

So this thread can get back to its original purpose ;)

Bables55 commented 7 years ago

I also want this function to be realized. If I want more hope, I would like this to be the specification and function of Nextcloud instead of the application. Similar things happen in Collabora Online.

The bigger influence is the double-byte character input on the smartphone. Double-byte characters can't be entered correctly. There is no problem with mail application that don't use "Auto Save".

rNoz commented 6 years ago

Exactly as @Rocreex says.

olpo24 commented 4 years ago

Any news on this? It would be wonderful to be able to change the auto-save time or even switch auto-save off.