Группа :: Графические оболочки/KDE
Пакет: kdelibs
Главная Изменения Спек Патчи Загрузить Bugs and FR
Патч: post-3.3.2-kdelibs-kate.diff
Index: kate/part/katedocument.cpp
===================================================================
--- kate/part/katedocument.cpp (revision 433695)
+++ kate/part/katedocument.cpp (revision 433696)
@@ -47,7 +47,9 @@
#include <kio/job.h>
#include <kio/netaccess.h>
+#include <kio/kfileitem.h>
+
#include <kparts/event.h>
#include <klocale.h>
@@ -2619,14 +2621,38 @@
bool KateDocument::save()
{
- // FIXME reorder for efficiency, prompt user in case of failure
bool l ( url().isLocalFile() );
- if ( ( ( l && config()->backupFlags() & KateDocumentConfig::LocalFiles ) ||
- ( ! l && config()->backupFlags() & KateDocumentConfig::RemoteFiles ) )
- && isModified() ) {
+
+ if ( ( l && config()->backupFlags() & KateDocumentConfig::LocalFiles )
+ || ( ! l && config()->backupFlags() & KateDocumentConfig::RemoteFiles ) )
+ {
KURL u( url().directory(false) + config()->backupPrefix() + url().fileName() + config()->backupSuffix() );
- if ( ! KIO::NetAccess::upload( url().path(), u, kapp->mainWidget() ) )
+
+ kdDebug () << "backup src file name: " << url() << endl;
+ kdDebug () << "backup dst file name: " << u << endl;
+
+ // get the right permissions, start with safe default
+ mode_t perms = 0600;
+ KIO::UDSEntry fentry;
+ if (KIO::NetAccess::stat (url(), fentry, kapp->mainWidget()))
+ {
+ kdDebug () << "stating succesfull: " << url() << endl;
+ KFileItem item (fentry, url());
+ perms = item.permissions();
+ }
+
+ // first del existing file if any, than copy over the file we have
+ // failure if a: the existing file could not be deleted, b: the file could not be copied
+ if ( (!KIO::NetAccess::exists( u, false, kapp->mainWidget() ) || KIO::NetAccess::del( u, kapp->mainWidget() ))
+ && KIO::NetAccess::file_copy( url(), u, perms, true, false, kapp->mainWidget() ) )
+ {
+ kdDebug(13020)<<"backing up successfull ("<<url().prettyURL()<<" -> "<<u.prettyURL()<<")"<<endl;
+ }
+ else
+ {
kdDebug(13020)<<"backing up failed ("<<url().prettyURL()<<" -> "<<u.prettyURL()<<")"<<endl;
+ // FIXME: notify user for real ;)
+ }
}
return KParts::ReadWritePart::save();