feat: expose file trash metadata

This commit is contained in:
2026-06-28 17:03:12 +08:00
parent ed4b117a94
commit e5bdaec0aa
9 changed files with 145 additions and 1 deletions
+15
View File
@@ -972,6 +972,21 @@ func (a *App) TrashVaultPath(pluginID, relativePath string) (corefiles.TrashResu
return result, ""
}
// ListVaultTrash returns trash metadata entries for a plugin with files.delete.
func (a *App) ListVaultTrash(pluginID string) ([]corefiles.TrashEntry, string) {
if _, err := a.requirePluginAccess(pluginID, "files.delete"); err != nil {
return nil, err.Error()
}
if a.files == nil {
return nil, "files service not initialized"
}
entries, err := a.files.ListTrashEntries()
if err != nil {
return nil, err.Error()
}
return entries, ""
}
// OpenVaultPathExternal opens a vault-relative file or folder in the OS default app.
func (a *App) OpenVaultPathExternal(pluginID, relativePath string) string {
if _, err := a.requirePluginAccess(pluginID, "files.openExternal"); err != nil {
+7
View File
@@ -388,6 +388,13 @@ func TestFilesBridgeReadWriteListMoveTrash(t *testing.T) {
if _, err := os.Stat(filepath.Join(root, trash.TrashPath)); err != nil {
t.Fatalf("trash path missing: %v", err)
}
trashEntries, errStr := app.ListVaultTrash("files.plugin")
if errStr != "" {
t.Fatalf("ListVaultTrash: %s", errStr)
}
if len(trashEntries) != 1 || trashEntries[0].OriginalPath != "Docs/two.txt" || trashEntries[0].TrashID != trash.TrashID {
t.Fatalf("trash entries = %+v, want Docs/two.txt", trashEntries)
}
}
func TestFilesBridgeWritePublishesFileChangedActivityEvent(t *testing.T) {