Skip to content
Draft
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
16 changes: 16 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
"delete-from-trash": "Delete from Trash",
"delete-permanently": "Delete permanently",
"deleted": "Deleted",
"deleted-permanently": "Permanently deleted",
"deletion-unconfirmed": "Deletion unconfirmed",
"done-count-files": "{done}/{count}{plus} files",
"done-count-files-plural": "{done}/{count}{plus} files",
Expand Down Expand Up @@ -532,6 +533,8 @@
"could-not-create-folder": "Could not create the folder.",
"could-not-prepare-destination": "Could not prepare the destination.",
"could-not-request-extraction": "Could not request extraction: {error}",
"could-not-move-to-trash": "Could Not Move to Trash",
"could-not-restore-the-item": "Could Not Restore the Item",
"could-not-start-moving-items": "Could not start moving the items out of Trash.",
"create-links-here": "Create Link Here",
"create-links-here-plural": "Create Links Here",
Expand All @@ -551,6 +554,8 @@
"incoming": "Incoming",
"item": "Item",
"item-already-exists": "Item Already Exists",
"item-not-trashed-keep-or-delete": "This storage does not accept a Trash folder, so the item could not be moved to Trash. Delete it permanently?",
"item-still-in-trash-keep-or-delete": "The item could not be moved to this location, so it was not restored. It is still in Trash: keep it there, or delete it permanently.",
"items-copied": "{count} item copied",
"items-copied-plural": "{count} items copied",
"items-linked": "{count} item linked",
Expand All @@ -562,6 +567,8 @@
"items-undone": "{count} item undone.",
"items-undone-plural": "{count} items undone.",
"keep-both": "Keep Both",
"keep-in-trash": "Keep in Trash",
"keep-the-item": "Keep the Item",
"merge": "Merge",
"merge-keeps-existing-contents-and": "Merge keeps existing contents and asks about conflicting children. Replace removes the whole existing folder.",
"modification-time-unknown": "Modification time unknown",
Expand Down Expand Up @@ -1957,8 +1964,17 @@
"trash-service": {
"containing-folder-changed-select-items-again": "The containing folder changed. Select the items again.",
"could-not-move-item-to-trash": "Could not move the item to Trash.",
"could-not-delete-item": "Could not delete the item.",
"item-kept-in-place": "The item was kept in place.",
"could-not-record-trash-deletion-date": "Could not record the Trash deletion date.",
"could-not-create-trash-info": "Could not create the Trash info file.",
"could-not-write-trash-info": "Could not write the Trash info file.",
"local-and-network-items-cannot": "Local and network items cannot be moved to Trash in one operation.",
"item-was-replaced-or-moved-select": "The item was replaced or moved. Select it again.",
"moving-remote-items-to-trash-is": "Moving remote items to Trash is not supported yet.",
"only-files-folders-and-links-can": "Only files, folders, and links can move to Trash.",
"this-storage-does-not-accept-trash": "This storage does not accept a Trash folder. Use Delete Permanently ({keybind}).",
"this-storage-does-not-accept-trash-no-keybind": "This storage does not accept a Trash folder. Use Delete Permanently (no keybind set).",
"trash-requires-native-items-from-expected": "Trash requires native items from the expected containing folders.",
"trash-selection-contains-invalid-or-repeated": "The Trash selection contains an invalid or repeated item.",
"trash-selection-contains-overlapping-items": "The Trash selection contains overlapping items."
Expand Down
20 changes: 16 additions & 4 deletions docs/user/trash.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@ Move files to Trash, restore them, or delete them permanently.

## Move to Trash

Press `Delete` or choose **Move to Trash** to send the selected native items to Trash. This also works on search results from different folders: only the selected items move, and the search stays active.
Press `Delete` or choose **Move to Trash** to send the selected items to Trash. This also works on search results from different folders: only the selected items move, and the search stays active.

### When a mount refuses Trash

Some mounts may refuse the system Trash service: nested btrfs subvolumes, system-internal mounts, and many NTFS, CIFS, or SMB shares. In those cases, Luciole writes a Trash folder (`.Trash-1000`) directly on that storage, at the mount point or the nearest folder boundary that can reach the item, so nothing is copied. The folder follows the freedesktop Trash layout for per-device Trash (`.Trash-1000` with `files/` and `info/`), with `Path=` recorded relative to that storage boundary. If the storage also rejects that folder, Luciole asks first; unless you confirm, nothing is deleted. The offer appears per item: **Keep the Item** leaves that item in place and continues with the rest, while closing the dialog cancels the whole operation.

### Network locations

Network locations (`sftp://`, `smb://`, and WebDAV) get the same treatment: the item is renamed into a `.Trash-1000` folder on the server, never downloaded. Browse such a folder, for example `sftp://server/.Trash-1000/files`, and its items offer **Restore** and **Delete Permanently** too. Local and network selections cannot be trashed in one operation; select them separately.

### Seeing staged items

The **Trash** view lists these staged items too: Luciole scans mounted drives up to three folder levels below each mount root for `.Trash-1000` folders and merges their contents into the listing. **Restore**, **Delete Permanently**, and **Empty Trash** work on them like on any other trashed item.

To find what takes up space before cleaning up, use [Disk Usage](disk-usage.md).

You can also drag native files and folders onto **Trash** in Places, including from another Luciole window. Copy-only drags, `Ctrl` copy, `Alt` action choices, remote files and archive extractions are rejected. A failed move never turns into permanent deletion.
You can also drag files and folders onto **Trash** in Places, including from another Luciole window. Copy-only drags, `Ctrl` copy, `Alt` action choices, and archive extractions are rejected. A failed move never turns into permanent deletion.

> [!NOTE]
> Trash, restore and Empty Trash need the system's Trash service and a session D-Bus connection. See [troubleshooting](troubleshooting.md) if they do nothing.
> The system Trash view and system Trash handling need the system's Trash service and a session D-Bus connection. Trash folders written on storages are scanned and listed even without them; reopen the Trash view to rescan. See [troubleshooting](troubleshooting.md) when Trash does nothing.

## Restore or delete trashed items

In Trash, **Restore** returns the selected items to their original locations and asks about conflicts. **Delete Permanently** removes them for good and follows **Settings → General → Confirm Permanent Deletion**.
In Trash, **Restore** returns the selected items to their original locations and asks about conflicts. **Delete Permanently** removes them for good and follows **Settings → General → Confirm Permanent Deletion**. If a restore would have to cross a boundary that rejects renames, Luciole copies the item and deletes the trashed original only after the copy succeeded; a failed copy asks whether to keep the item in Trash or discard it.

## Empty Trash

Expand Down
9 changes: 6 additions & 3 deletions src/app/job_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ namespace {
}
if (!job.running()) {
for (const auto& result : snapshot.results) {
if (result.outcome == luciole::TrashOutcome::Trashed) {
if (result.outcome == luciole::TrashOutcome::Trashed || result.outcome == luciole::TrashOutcome::Deleted) {
++counts.done;
} else if (result.outcome == luciole::TrashOutcome::Failed) {
++counts.failed;
Expand All @@ -615,8 +615,11 @@ namespace {
if (details) {
report.add(
itemName(result.source),
result.outcome == luciole::TrashOutcome::Trashed ? i18n::tr("app.job-activity.trashed")
: i18n::tr("app.job-activity.not-trashed"),
result.outcome == luciole::TrashOutcome::Trashed
? i18n::tr("app.job-activity.trashed")
: (result.outcome == luciole::TrashOutcome::Deleted
? i18n::tr("app.job-activity.deleted-permanently")
: i18n::tr("app.job-activity.not-trashed")),
result.error
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/operation_hub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ std::optional<luciole::TransferConflict> OperationJob::conflict() const {
return service<luciole::ArchiveService>().conflict();
case JobKind::Restore:
return service<luciole::RestoreService>().conflict();
case JobKind::Trash:
return service<luciole::TrashService>().conflict();
default:
return std::nullopt;
}
Expand All @@ -134,6 +136,8 @@ bool OperationJob::resolve(std::uint64_t id, luciole::TransferConflictChoice cho
return service<luciole::ArchiveService>().resolve(id, choice);
case JobKind::Restore:
return service<luciole::RestoreService>().resolve(id, choice);
case JobKind::Trash:
return service<luciole::TrashService>().resolve(id, choice);
default:
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/page/menu_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "core/deferred_call.h"
#include "fs/archive_type.h"
#include "fs/entry_access.h"
#include "fs/trash_info.h"
#include "i18n/i18n.h"
#include "platform/desktop_integration.h"
#include "platform/terminal_launcher.h"
Expand Down Expand Up @@ -243,7 +244,8 @@ std::vector<ContextMenuControlEntry> MenuController::itemMenuEntries(const lucio
const auto* single = one ? model.entry(request.targets.front().id) : nullptr;
const auto singleLocation = single ? std::optional(single->location()) : std::nullopt;
const bool singleFolder = single != nullptr && single->isFolderLink();
const bool trash = request.targets.front().location.isTrash();
const auto& firstTarget = request.targets.front().location;
const bool trash = firstTarget.isTrash() || luciole::isPhysicalTrashItem(firstTarget);

add(Action::Open);
if (singleFolder && !single->symlink && singleLocation->administratorLocation()) {
Expand Down
85 changes: 84 additions & 1 deletion src/app/page/transfer_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ void TransferController::trashDrop(
snapshot.status == luciole::TrashStatus::Finished
&& !snapshot.results.empty()
&& std::ranges::all_of(snapshot.results, [](const auto& result) {
return result.outcome == luciole::TrashOutcome::Trashed;
return result.outcome == luciole::TrashOutcome::Trashed
|| result.outcome == luciole::TrashOutcome::Deleted;
})
);
});
Expand Down Expand Up @@ -676,6 +677,10 @@ void TransferController::syncConflict() {
if (!conflict) {
return;
}
if (conflict->permanentDeleteOffer) {
showPermanentDeleteOffer(*job, *conflict);
return;
}
const bool archive = job->kind() == JobKind::Archive;
const bool restore = job->kind() == JobKind::Restore;
const bool permanentReplace = !archive && !restore;
Expand Down Expand Up @@ -845,6 +850,84 @@ void TransferController::syncConflict() {
}
}

void TransferController::showPermanentDeleteOffer(OperationJob& job, const luciole::TransferConflict& conflict) {
const bool stageFailure = conflict.trashStageFailure;
const ActiveConflict active{.job = job.id(), .conflict = conflict.id};
const float width = m_page.dialogWidth(DialogWidth::Medium);
const auto choose = [this, active](luciole::TransferConflictChoice choice) {
auto* owner = m_page.jobs().find(active.job);
if (owner && owner->resolve(active.conflict, choice, false)) {
m_activeConflict.reset();
m_page.dismissPopup();
}
};
Button* keepButton = nullptr;
auto root = ui::column(
{.align = FlexAlign::Stretch},
luciole::dialogHeader(
i18n::tr(
stageFailure ? "app.transfer-controller.could-not-move-to-trash"
: "app.transfer-controller.could-not-restore-the-item"
),
"alert-triangle", [choose] { choose(luciole::TransferConflictChoice::Cancel); }
),
ui::label(
{.text = conflict.name,
.maxWidth = width - 24.0F,
.maxLines = 2,
.configure = [](Label& name) { name.setUseMarkup(false); }}
),
ui::label(
{.text = luciole::locationEditText(conflict.destination),
.fontSize = Style::fontSizeCaption,
.color = colorSpecFromRole(ColorRole::OnSurfaceVariant),
.maxWidth = width - 24.0F,
.maxLines = 2,
.configure = [](Label& path) { path.setUseMarkup(false); }}
),
ui::separator({}),
ui::label(
{.text = i18n::tr(
stageFailure ? "app.transfer-controller.item-not-trashed-keep-or-delete"
: "app.transfer-controller.item-still-in-trash-keep-or-delete"
),
.maxWidth = width - 24.0F,
.maxLines = 3}
),
ui::row(
{.align = FlexAlign::Center, .justify = FlexJustify::End, .gap = Style::spaceSm},
ui::button(
{.out = &keepButton,
.text = i18n::tr(
stageFailure ? "app.transfer-controller.keep-the-item" : "app.transfer-controller.keep-in-trash"
),
.variant = ButtonVariant::Primary,
.onClick = [choose] { choose(luciole::TransferConflictChoice::Skip); }}
),
ui::button(
{.text = i18n::tr("browser.action-registry.delete-permanently"),
.variant = ButtonVariant::Destructive,
.onClick = [choose] { choose(luciole::TransferConflictChoice::Replace); }}
)
)
);
luciole::applyDialogStyle(*root);
m_page.showDialog(std::move(root), DialogWidth::Medium);
if (m_page.popupSurface() != nullptr) {
m_page.activePopup().bind(ActivePopup::Kind::TransferConflict, [this] {
if (const auto shown = std::exchange(m_activeConflict, std::nullopt)) {
if (auto* owner = m_page.jobs().find(shown->job)) {
(void)owner->resolve(shown->conflict, luciole::TransferConflictChoice::Cancel);
}
}
});
m_activeConflict = active;
m_page.popupDispatcher().setFocus(keepButton->inputArea());
} else {
(void)job.resolve(conflict.id, luciole::TransferConflictChoice::Cancel);
}
}

void TransferController::retry(luciole::JobId target) {
auto* job = m_page.jobs().find(target);
if (m_page.operationsBusy()
Expand Down
2 changes: 2 additions & 0 deletions src/app/page/transfer_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "clipboard/text_clipboard.h"
#include "core/timer_manager.h"
#include "fs/transfer_types.h"
#include "operations/transfer_service.h"
#include "platform/extraction_launcher.h"

#include <cstdint>
Expand Down Expand Up @@ -69,6 +70,7 @@ class TransferController {
void updateOperationProgress();
// Retries a completed owned transfer, preserving the clipboard move claim workflow.
void retry(luciole::JobId target);
void showPermanentDeleteOffer(OperationJob& job, const luciole::TransferConflict& conflict);

// Page teardown: stop the tick.
void stopProgress();
Expand Down
10 changes: 9 additions & 1 deletion src/app/page/trash_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,19 @@ void TrashController::trashChanged(OperationJob& job) {
} else if (snapshot.status == luciole::TrashStatus::Finished) {
const auto done =
std::ranges::count(snapshot.results, luciole::TrashOutcome::Trashed, &luciole::TrashResult::outcome);
const auto deleted =
std::ranges::count(snapshot.results, luciole::TrashOutcome::Deleted, &luciole::TrashResult::outcome);
const auto failed =
std::ranges::count(snapshot.results, luciole::TrashOutcome::Failed, &luciole::TrashResult::outcome);
const auto cancelled =
std::ranges::count(snapshot.results, luciole::TrashOutcome::Cancelled, &luciole::TrashResult::outcome);
std::string message = i18n::trp("app.trash-controller.items-moved-to-trash", done);
std::string message;
if (done != 0) {
message = i18n::trp("app.trash-controller.items-moved-to-trash", done);
}
if (deleted != 0) {
message += (message.empty() ? "" : " · ") + i18n::trp("app.trash-controller.items-permanently-deleted", deleted);
}
if (failed != 0) {
message += " · " + i18n::tr("app.trash-controller.count-failed", "count", failed);
}
Expand Down
20 changes: 9 additions & 11 deletions src/browser/action_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "fs/archive_type.h"
#include "fs/entry_access.h"
#include "fs/transfer_types.h"
#include "fs/trash_info.h"

#include <algorithm>
#include <array>
Expand Down Expand Up @@ -141,9 +142,7 @@ namespace {
if (!rename && (!ready(c) || r.targets.size() > 4096)) {
return unavailable("browser.action-registry.select-at-most-4096-native-items");
}
if (!all(c, r, [&](const DirectoryEntry& entry) {
return (rename ? entry.access.rename : entry.access.trash).value_or(true);
})) {
if (rename && !all(c, r, [&](const DirectoryEntry& entry) { return entry.access.rename.value_or(true); })) {
return unavailable("browser.action-registry.provider-does-not-permit-this-operation");
}
return {};
Expand All @@ -169,23 +168,22 @@ namespace {
if (const auto state = writable(c); !state.enabled) {
return state;
}
if (r.folder != luciole::Location::trash() || !c.query.empty() || !ready(c)) {
const bool trashView =
r.folder && (*r.folder == luciole::Location::trash() || luciole::physicalTrashFolders(*r.folder).has_value());
if (!trashView || !c.query.empty() || !ready(c)) {
return unavailable("browser.action-registry.select-items-directly-in-trash-first");
}
if (!all(c, r, [](const DirectoryEntry& entry) {
const auto location = entry.location();
const auto parent = location.parent();
return location.isTrash()
&& parent
&& *parent == luciole::Location::trash()
const auto topLevel = location.isTrash() && parent && *parent == luciole::Location::trash();
return (topLevel || luciole::isPhysicalTrashItem(location))
&& entry.identity().has_value()
&& entry.access.remove.value_or(true);
})) {
return unavailable("browser.action-registry.these-items-cannot-be-changed-by");
}
if (restore && !all(c, r, [](const DirectoryEntry& entry) {
return entry.trashInfo().original && entry.trashInfo().original->nativePath().has_value();
})) {
if (restore && !all(c, r, [](const DirectoryEntry& entry) { return entry.trashInfo().original.has_value(); })) {
return unavailable("browser.action-registry.original-location-is-unavailable-for-one");
}
return {};
Expand Down Expand Up @@ -709,7 +707,7 @@ namespace {
.destructive = true,
.rule =
[](const C& c, const R& r) {
if (r.folder && r.folder->isTrash()) {
if (r.folder && (r.folder->isTrash() || luciole::physicalTrashFolders(*r.folder).has_value())) {
return trashItems(c, r, false);
}
if (const auto state = writable(c); !state.enabled) {
Expand Down
Loading
Loading