[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    [Bug 76942] file saving, consider vi like save to new file, unlink
From:       Nicolas Bigaouette <nbigaouette () gmail ! com>
Date:       2009-04-29 13:59:50
Message-ID: 20090429135950.3713516508 () immanuel ! kde ! org
[Download RAW message or body]

https://bugs.kde.org/show_bug.cgi?id=76942





--- Comment #23 from Nicolas Bigaouette <nbigaouette gmail com>  2009-04-29 15:59:45 ---
It's the first time I jump into KDE's code. I'll ask for advice before
modifying something ;)

I'm looking at kdelibs-4.2.2/kate/document/katedocument.cpp. At line 3501, the
function "bool KateDocument::saveFile()" is defined. At line 3555, there is a
check against the "create backup file" configuration. Some work is done after,
but at line 3634, a call to "deactivateDirWatch ();" is done. Then the saving
is done.

What could be problematic is that the saving is done without any failsafe. A
refactoring might be (over simplified to) saving to a temporary file, verifying
it, and move it to original file instead of plainly save, verify, bail-out if
something goes wrong.

Refactoring that part to something similar to comment #13 :
1. Save file content to temporary ".tmp_foo"
2. If backup should be done, copy "foo" to "prefixfoosuffix"
3. Copy temporary file ".tmp_foo" to "foo"
4. If succeeded, remove temporary file ".tmp_foo"
A lot of failsafe should appear around each of these steps.

I need to go for an hour or two. I'll try to post back after that :)

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic