kioslave: remove trash migration code

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-27 09:10:47 +03:00
parent cf6d91b6a1
commit 69524945c5
7 changed files with 25 additions and 73 deletions

View file

@ -112,7 +112,7 @@ void PlacesPanel::showEvent(QShowEvent* event)
m_controller->setSelectionBehavior(KItemListController::SingleSelection);
m_controller->setSingleClickActivationEnforced(true);
readSettings();
readSettings();
connect(m_controller, SIGNAL(itemActivated(int)), this, SLOT(slotItemActivated(int)));
connect(m_controller, SIGNAL(itemMiddleClicked(int)), this, SLOT(slotItemMiddleClicked(int)));

View file

@ -471,27 +471,24 @@ void TrashProtocol::special( const QByteArray & data )
stream >> cmd;
switch (cmd) {
case 1:
if ( impl.emptyTrash() )
finished();
else
error( impl.lastErrorCode(), impl.lastErrorMessage() );
break;
case 2:
impl.migrateOldTrash();
finished();
break;
case 3:
{
KUrl url;
stream >> url;
restore( url );
break;
}
default:
kWarning() << "Unknown command in special(): " << cmd ;
error( KIO::ERR_UNSUPPORTED_ACTION, QString::number(cmd) );
break;
case 1: {
if ( impl.emptyTrash() )
finished();
else
error( impl.lastErrorCode(), impl.lastErrorMessage() );
break;
}
case 2: {
KUrl url;
stream >> url;
restore( url );
break;
}
default: {
kWarning() << "Unknown command in special(): " << cmd ;
error( KIO::ERR_UNSUPPORTED_ACTION, QString::number(cmd) );
break;
}
}
}

View file

@ -70,8 +70,8 @@ int main(int argc, char *argv[])
QByteArray packedArgs;
QDataStream stream(&packedArgs, QIODevice::WriteOnly);
stream << (int)3 << trashURL;
KIO::Job* job = KIO::special( trashURL, packedArgs );
stream << (int)2 << trashURL;
KIO::Job* job = KIO::special(trashURL, packedArgs);
bool ok = KIO::NetAccess::synchronousRun(job, 0);
if (!ok) {
kError() << KIO::NetAccess::lastErrorString();

View file

@ -927,7 +927,7 @@ void TestTrash::restoreFile()
QByteArray packedArgs;
QDataStream stream( &packedArgs, QIODevice::WriteOnly );
stream << (int)3 << url;
stream << (int)2 << url;
KIO::Job* job = KIO::special( url, packedArgs, KIO::HideProgressInfo );
bool ok = KIO::NetAccess::synchronousRun( job, 0 );
QVERIFY( ok );
@ -953,7 +953,7 @@ void TestTrash::restoreFileFromSubDir()
QByteArray packedArgs;
QDataStream stream( &packedArgs, QIODevice::WriteOnly );
stream << (int)3 << url;
stream << (int)2 << url;
KIO::Job* job = KIO::special( url, packedArgs, KIO::HideProgressInfo );
bool ok = KIO::NetAccess::synchronousRun( job, 0 );
QVERIFY( !ok );
@ -987,7 +987,7 @@ void TestTrash::restoreFileToDeletedDirectory()
QByteArray packedArgs;
QDataStream stream( &packedArgs, QIODevice::WriteOnly );
stream << (int)3 << url;
stream << (int)2 << url;
KIO::Job* job = KIO::special( url, packedArgs, KIO::HideProgressInfo );
bool ok = KIO::NetAccess::synchronousRun( job, 0 );
QVERIFY( !ok );

View file

@ -168,48 +168,6 @@ bool TrashImpl::init()
return true;
}
void TrashImpl::migrateOldTrash()
{
kDebug() ;
KConfigGroup g( KGlobal::config(), "Paths" );
const QString oldTrashDir = g.readPathEntry( "Trash", QString() );
if ( oldTrashDir.isEmpty() )
return;
const QStringList entries = listDir( oldTrashDir );
bool allOK = true;
for ( QStringList::const_iterator entryIt = entries.begin(), entryEnd = entries.end();
entryIt != entryEnd ; ++entryIt )
{
QString srcPath = *entryIt;
if ( srcPath == QLatin1String(".") || srcPath == QLatin1String("..") || srcPath == QLatin1String(".directory") )
continue;
srcPath.prepend( oldTrashDir ); // make absolute
int trashId;
QString fileId;
if ( !createInfo( srcPath, trashId, fileId ) ) {
kWarning() << "Trash migration: failed to create info for " << srcPath ;
allOK = false;
} else {
bool ok = moveToTrash( srcPath, trashId, fileId );
if ( !ok ) {
(void)deleteInfo( trashId, fileId );
kWarning() << "Trash migration: failed to create info for " << srcPath ;
allOK = false;
} else {
kDebug() << "Trash migration: moved " << srcPath;
}
}
}
if ( allOK ) {
// We need to remove the old one, otherwise the desktop will have two trashcans...
kDebug() << "Trash migration: all OK, removing old trash directory";
synchronousDel( oldTrashDir, false, true );
}
}
bool TrashImpl::createInfo( const QString& origPath, int& trashId, QString& fileId )
{
kDebug() << origPath;

View file

@ -92,9 +92,6 @@ public:
/// encapsulates the call to infoForFile. Don't use if you need more info from TrashedFileInfo.
QString physicalPath( int trashId, const QString& fileId, const QString& relativePath );
/// Move data from the old trash system to the new one
void migrateOldTrash();
/// KIO error code
int lastErrorCode() const { return m_lastErrorCode; }
QString lastErrorMessage() const { return m_lastErrorMessage; }

View file

@ -927,7 +927,7 @@ void KonqMultiRestoreJob::slotStart()
Q_ASSERT( new_url.protocol() == "trash" );
QByteArray packedArgs;
QDataStream stream( &packedArgs, QIODevice::WriteOnly );
stream << (int)3 << new_url;
stream << (int)2 << new_url;
KIO::Job* job = KIO::special( new_url, packedArgs, KIO::HideProgressInfo );
addSubjob( job );
setProcessedAmount(KJob::Files, processedAmount(KJob::Files) + 1);