Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ class FileProviderMaterialisedEnumerationObserver: NSObject, NSFileProviderEnume
}

func didEnumerate(_ updatedItems: [NSFileProviderItemProtocol]) {
let updatedItemsIds = Array(updatedItems.map(\.itemIdentifier.rawValue))
// Filter out items that are in the trash container to prevent server-trashed
// items from appearing in the macOS Trash. Server trash items should only
// be managed through the Nextcloud web interface or desktop client.
let nonTrashItems = updatedItems.filter { item in
item.parentItemIdentifier != .trashContainer
}

let updatedItemsIds = Array(nonTrashItems.map(\.itemIdentifier.rawValue))

for updatedItemsId in updatedItemsIds {
allEnumeratedItemIds.insert(updatedItemsId)
Expand Down
20 changes: 20 additions & 0 deletions src/gui/macOS/fileprovidersettingscontroller_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "fileprovidersettingscontroller.h"

#include <QFileDialog>
#include <QMessageBox>
#include <QQmlApplicationEngine>

#include "gui/systray.h"
Expand Down Expand Up @@ -269,6 +270,25 @@ void initialCheck()
return;
}

// Show warning dialog when enabling permanent deletion
if (setEnabled) {
const auto result = QMessageBox::warning(
nullptr,
tr("Enable permanent file deletion?"),
tr("When you delete files from the virtual drive in Finder, they will be permanently deleted from the server.\n\n"
"This action cannot be undone. The files will NOT go to the server's trash and cannot be restored.\n\n"
"Are you sure you want to enable this feature?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);

if (result != QMessageBox::Yes) {
// User cancelled, reset UI state
emit trashDeletionEnabledForAccountChanged(userIdAtHost);
emit trashDeletionSetForAccountChanged(userIdAtHost);
return;
}
}

const auto domainId = FileProviderUtils::domainIdentifierForAccountIdentifier(userIdAtHost);

xpc->setTrashDeletionEnabledForFileProviderDomain(domainId, setEnabled);
Expand Down
23 changes: 22 additions & 1 deletion src/gui/macOS/ui/FileProviderSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,30 @@ Page {
}

CheckBox {
text: qsTr("Allow deletion of items in Trash")
id: trashDeletionCheckBox
text: qsTr("Permanently delete files when removed from virtual drive")
checked: root.controller.trashDeletionEnabledForAccount(root.accountUserIdAtHost)
onClicked: root.controller.setTrashDeletionEnabledForAccount(root.accountUserIdAtHost, checked)

Connections {
target: root.controller
function onTrashDeletionEnabledForAccountChanged(accountUserIdAtHost) {
if (root.accountUserIdAtHost !== accountUserIdAtHost) {
return;
}
trashDeletionCheckBox.checked = root.controller.trashDeletionEnabledForAccount(root.accountUserIdAtHost);
}
}
}

EnforcedPlainTextLabel {
Layout.fillWidth: true
Layout.leftMargin: trashDeletionCheckBox.indicator.width + trashDeletionCheckBox.spacing
visible: trashDeletionCheckBox.checked
text: qsTr("⚠️ Warning: Deleted files will be permanently removed from the server and cannot be restored!")
color: "#cc0000"
wrapMode: Text.WordWrap
font.italic: true
}
}
}