Text truncated when I save a txt file during a sftp session over nautilus

Bug #708829 reported by Sergio Rus on 2011-01-27
This bug affects 13 people
Affects Status Importance Assigned to Milestone
leafpad (Debian)
leafpad (Ubuntu)

Bug Description

Binary package hint: leafpad

When I save a txt file during a sftp session over nautilus, there is a piece of text that is always truncated. It seems like it happens only with this txt file (see the attached file). If I repeat the same process over a ssh -X session (in a terminal), everything is ok: the saved file is correct.

Sergio Rus (srus) wrote :
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in leafpad (Ubuntu):
status: New → Confirmed
Petr Flídr (petrf) wrote :

This problem happens when file is XML opened over PCManFM too.

Nicolas (pathogenyx) wrote :

Same bug under debian with leafpad : in a sftp directory mounted with nautilus, after editing and saving a text file with leafpad, my text file get truncated (at exactly 4096 bytes ...). There's no problem when editing/saving it with gedit though.

Nicolas (pathogenyx) wrote :

After a few tries, I think I can say the bug is not related to leafpad per se, but to gvfs and fuse :

I checked the length returned by the "fwrite()" in the save function of leafpad (file_save_real in file.c) and it returns a value > 4096 bytes. But the file on the gvfs is only 4096 byte long.

Searching for "gvfs truncate" issues returns lot of results : seems gvfs is not fully compatible with POSIX api (like the basic and standard fwrite function used by leafpad or emacs) but should be used with gio api (probably used by gedit).

There's probably already a bug filled for this, so hopefully a futur release of gvfs will fix this.

quadra (info06) wrote :

It may be also a gvfs issue, but this affects data integrity and therefore it's a hot one. It's easy to loose files with this.
I think "importance" of this bug should be set to "high".

There must be a way to fix it in leafpad, not gvfs, as it doesn't appear when editing the same text files in gedit, nor in abiword.

I confirm this bug is still present till today [May, 2016].

I edited a *.txt file in leafpad over sftp in nautilus. After I saved the file in leafpad and exited, the file size became 0 bytes. It erased entire file contents upon saving! I am very disappointed, since I do not have the backup of the file.

I also think 'importance' of this bug should be set to "HIGH".

Ubuntu 15.10

hippieshaker (bladeboy2000au) wrote :

I'm not sure if it's the same issue as originally reported, but I confirm the behaviour Surendra has reported. It happens on SFTP/SSH connections as well as SMB, and seems to only occur on text files less than 4096 bytes. Yes this is a dangerous bug - I was just lucky to notice before losing important notes.

If you reverse lines 232 & 233 in src/file.c so that it becomes:
  gtk_text_buffer_set_modified(buffer, FALSE);

and recompile it seems to fix the bug - the files save correctly. There must be some issue between GVFS and gtk_text_buffer_set_modified where the buffer is lost.

EB (ebreport) wrote :

I have the same problem, so I confirm it is still a bug [October, 2016]. Indeed a dangerous bug. Lucky I found old files in my backup.

Juhani Numminen (jsonic) on 2018-12-09
Changed in leafpad (Debian):
importance: Undecided → Unknown
status: New → Unknown
Changed in leafpad (Debian):
status: Unknown → New
Changed in leafpad (Debian):
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.