Skip to content

Commit

Permalink
fix: display issue of naming conflicts in shared folders
Browse files Browse the repository at this point in the history
Unable to display file sharing status properly during naming conflicts

Log: Restore the file state to the previous state when a naming conflict user cancels the operation

Bug: https://pms.uniontech.com/bug-view-259627.html
  • Loading branch information
yang233000 authored and max-lvs committed Jun 25, 2024
1 parent 46b793f commit b0efe6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ bool ShareControlWidget::validateShareName()
}

if (dlg.exec() != DDialog::Accepted) {
if(isShared){
QString filePath = url.path();
auto shareName = UserShareHelperInstance->shareNameByPath(filePath);
shareNameEditor->setText(shareName);
shareSwitcher->setChecked(isShared);
}
shareNameEditor->setFocus();
return false;
}
Expand All @@ -457,18 +463,24 @@ bool ShareControlWidget::validateShareName()

void ShareControlWidget::updateShare()
{
shareFolder();
if (!isUpdating)
shareFolder();
return;
}

void ShareControlWidget::shareFolder()
{
bool isShared = UserShareHelperInstance->isShared(url.path());
if (!shareSwitcher->isChecked())
return;

isUpdating = true;
if (!validateShareName()) {
shareSwitcher->setChecked(false);
sharePermissionSelector->setEnabled(false);
shareAnonymousSelector->setEnabled(false);
if(!isShared){
shareSwitcher->setChecked(false);
sharePermissionSelector->setEnabled(false);
shareAnonymousSelector->setEnabled(false);
}
isUpdating = false;
return;
}

Expand Down Expand Up @@ -512,6 +524,7 @@ void ShareControlWidget::shareFolder()
sharePermissionSelector->setEnabled(false);
shareAnonymousSelector->setEnabled(false);
}
isUpdating = false;
}

void ShareControlWidget::unshareFolder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected Q_SLOTS:
QTimer *timer { Q_NULLPTR };

QUrl url;
bool isUpdating { false };
FileInfoPointer info { Q_NULLPTR };
AbstractFileWatcherPointer watcher { Q_NULLPTR };
};
Expand Down

0 comments on commit b0efe6c

Please sign in to comment.