feat: expose file trash metadata
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user