mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 21:35:47 +03:00
Fixed bug where local files and directories where not properly deleted.
Also added proper parent to the QMessageBox
This commit is contained in:
parent
da60594a5e
commit
a0b3249419
2 changed files with 22 additions and 9 deletions
|
@ -1110,8 +1110,9 @@ void OwnCloudSync::localFileChanged(QString name)
|
|||
void OwnCloudSync::scanLocalDirectoryForNewFiles(QString path)
|
||||
{
|
||||
QString remote;
|
||||
path = path=="/"?"":path;
|
||||
if(mRemoteDirectory != "/") {
|
||||
remote = mRemoteDirectory;
|
||||
remote = mRemoteDirectory+"/";
|
||||
}
|
||||
//qDebug() << "Scanning local directory: " << path;
|
||||
QDir dir(mLocalDirectory+path);
|
||||
|
@ -1134,6 +1135,7 @@ void OwnCloudSync::scanLocalDirectoryForNewFiles(QString path)
|
|||
"file_name='%1/'").arg(path+remote+list[i]));
|
||||
if( !query.next() ) { // Definitely does not exist! Good!
|
||||
// File really doesn't exist!!!
|
||||
//qDebug() << "New file found!" << path +remote + list[i];
|
||||
processLocalFile(mLocalDirectory+path+list[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1203,8 +1205,8 @@ void OwnCloudSync::deleteRemovedFiles()
|
|||
while(server.next()) {
|
||||
// Server files were deleted. Delete from local too.
|
||||
qDebug() << "Deleting file from local: " << server.value(0).toString();
|
||||
emit toLog(tr("Deleting local file: %1").arg(
|
||||
server.value(0).toString()));
|
||||
//emit toLog(tr("Deleting local file: %1").arg(
|
||||
// server.value(0).toString()));
|
||||
deleteFromLocal(server.value(0).toString(),false);
|
||||
}
|
||||
|
||||
|
@ -1221,12 +1223,23 @@ void OwnCloudSync::deleteRemovedFiles()
|
|||
void OwnCloudSync::deleteFromLocal(QString name, bool isDir)
|
||||
{
|
||||
// Remove the watcher before deleting.
|
||||
mFileWatcher->removePath(mLocalDirectory+name);
|
||||
if( !QFile::remove(mLocalDirectory+name ) ) {
|
||||
qDebug() << "File deletion failed: " << mLocalDirectory+name;
|
||||
QString localName = stringRemoveBasePath(name,mRemoteDirectory);
|
||||
mFileWatcher->removePath(mLocalDirectory+localName);
|
||||
if(!isDir) {
|
||||
if( !QFile::remove(mLocalDirectory+localName ) ) {
|
||||
qDebug() << "File deletion failed: " << mLocalDirectory+localName;
|
||||
return;
|
||||
}
|
||||
emit toLog(tr("Deleting local file: %1").arg(name));
|
||||
emit toLog(tr("Deleted local file: %1").arg(name));
|
||||
} else {
|
||||
QDir dir;
|
||||
if( !dir.rmdir(mLocalDirectory+localName) ) {
|
||||
qDebug() << "Directory deletion failed: "
|
||||
<< mLocalDirectory+localName;
|
||||
return;
|
||||
}
|
||||
emit toLog(tr("Deleted local directory: %1").arg(name));
|
||||
}
|
||||
dropFromDB("local_files","file_name",name);
|
||||
dropFromDB("server_files","file_name",name);
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ void SyncWindow::closeEvent(QCloseEvent *event)
|
|||
{
|
||||
if(mQuitAction || !ui->actionClose_Button_Hides_Window->isChecked()) {
|
||||
// Ask the user for confirmation before closing!
|
||||
QMessageBox box;
|
||||
QMessageBox box(this);
|
||||
box.setText(tr("Are you sure you want to quit? "
|
||||
"Program will not quit until all required syncs are made."));
|
||||
box.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
|
||||
|
@ -719,7 +719,7 @@ void SyncWindow::on_buttonDeleteAccount_clicked()
|
|||
void SyncWindow::deleteAccount()
|
||||
{
|
||||
// Confirm from user if they want to delete the account
|
||||
QMessageBox box;
|
||||
QMessageBox box(this);
|
||||
box.setText(tr("Are you sure you want to delete account: %1").arg(
|
||||
mAccounts[mEditingConfig]->getName()));
|
||||
box.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
|
||||
|
|
Loading…
Reference in a new issue